constanly update a variable with position from input event screen drag

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kietjay123

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

:bust_in_silhouette: Reply From: USBashka

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: