Godot Version
4.2.2
Hello,
I am trying to create some gesture touch controls for my mobile game. The issue I am encountering is, that I am using InputEventScreenDrag for this and this calculates the relative position of the gesture for every frame.
InputEventScreenDrag doesnt support the _is_pressed method.
This means, that I print at the moment “right” or “left” every frame while I am dragging. Which is not the wanted behavior because this would trigger the controls every frame. I just want one trigger for every gesture. I want it to activate once and be only called again once another drag Event is being started.
How can I distinguish a full drag event? or achieve the above stated?
func _input(event):
if event is InputEventScreenTouch:
if event.is_pressed():
pass
#total_drag_distance = Vector2.ZERO
elif event.is_released():
pass
elif event is InputEventScreenDrag:
# get the total_drag distance in x and y (Vector2). This value starts at zero for every event
total_drag_distance = Vector2(0,0)
total_drag_distance += event.relative
is a good value to distinguish a swipe from a pressed gesture
if total_drag_distance.x >=40:
print('right')
elif total_drag_distance.x <= -40:
print('left')
print(total_drag_distance)
Best regards,
Jayme