Dragging to fast

Godot Version



If dragging to fast you lose the track. Any ideas ?


var state = {}

func _input(event):
	if event is InputEventScreenTouch:
		if event.pressed:
			state[event.index] = event.position
	elif event is InputEventScreenDrag:
		state[event.index] = event.position

1 Like

I think that your code would be fixed if you just make this:

func _process():
   position = get_global_mouse_position()

I guess you mean replacing your code with mine? This code piece of mine is able to take several inputs at the same time from different fingers.

If you want to take more than 1 input (fingers), you could transform the event position to a global position and then just set it. Make that for each input should work.

Invalid get index “global_position” on base InputEventScreenTouch. There is no method for global position in InputEventScreenTouch. May be you can give an example of your idea?

One question, why did you added the get_tree().set_input_as_handled()? You can’t touch under your screen, no?

I took it from the Multitouch Demo in the asset library, i thought its for marking the input as handled but i also tried to comment this part out but with the same result.

Ok, could you send the part of the code where you move the sprites so that I can see it?

I use TextureButton’s for having all the control methods on godot 3.5

func _process(delta):
	for touches in touch_help.state.keys():
		if node1.get_rect().has_point(touch_help.state[touches]):
			node1.rect_position = touch_help.state[touches] - node1.rect_size / 2
		elif node2.get_rect().has_point(touch_help.state[touches]):
			node2.rect_position = touch_help.state[touches] - node2.rect_size / 2
  • node1/node2 are TextureButtons
  • touch_help is the script from above
  • node.rect_size /2 is to place them in the midle of the event

i tried to use rect_global_position here instead but also didnt fixed it.

1 Like

If that doesn’t works, I don’t know what else you can do…

1 Like