Hi, there. I wanna hold the touch and while holding it, instance some sprites continuously. I can handle the instance part, but dont now how the hold part.

i did try few things like

var touch_position


func _input(event):
     if not event is Inputeventscreentouch:
          return
     if event.pressed:
          touch_position = event.position

this is only return the value one time. i need it the update at it every frame so i need the use func _process function, but how can i reach the touch_position variable from _process function ?

I would try something like this:

var touch_position = null
var is_touch_held = false

func _process(delta):
	if (is_touch_held == true and touch_position != null):
		print ("Touch is at: ", touch_position)

func _input(event):
	if event is InputEventScreenTouch:
		if (event.pressed == true):
			is_touch_held = true
			touch_position = event.position
		else:
			is_touch_held = false
			touch_position = null
	elif event is InputEventScreenDrag:
		touch_position = event.position
2 years later