0 votes

my game require constant update of a var with a drag gesture postion as my finger is moving on the touch sreen please help as im pretty new to programming

in Engine by (41 points)

1 Answer

0 votes

It can be done with this code:

var point_pos = Vector2(0, 0)  # Position will be here as Vector2

func _input(event):
    if event is InputEventScreenDrag:
        point_pos = event.position

It will works only with drags. If you want to handle single-point tap or touch, you should use InputEventScreenTouch. So you can use that event types together:

if event is InputEventScreenTouch or event is InputEventScreenDrag:
by (654 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.