How to get position of a finger in multitouch event?

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

Unity for example has this Input.GetTouch(1).position. I can’t seem to find an alternative in Godot

:bust_in_silhouette: Reply From: wombatstampede

The event variable you get passed in the input handler (i.e. _input(event) or _gui_input(event)) is of the type InputEventScreenTouch.

https://docs.godotengine.org/en/3.1/classes/class_inputeventscreentouch.html#class-inputeventscreentouch

You can check this that way:

if event is InputEventScreenTouch:
   print("Touch event: index "+str(event.index)+" pressed: "+str(event.pressed)+" position "+str(event.position))

The index attribute can be used to differentiate different touch events. It could be 1 for the first finger touching and 2 for the second simultaneous finger on the touch screen.

Well, it’s not quite right, because the index starts with 0, but the problem here is that I need to store the first finger position from one call and only then make some necessary calculations making it really messy, while in Unity you can get it any time you need it so I asked if there is something like that in Godot

jackash | 2019-05-09 17:13

The index starts with 0 because the array first element’s index is 0.

nightrobin | 2020-05-18 13:23