How to handle multiple touches at once

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rustyStriker
:warning: Old Version Published before Godot 3 was released.

Hi, i am in the making of a simple game and i want to make it for android. And i want to work it mostly through code, therefore i need to handle multiple touches at once.

:bust_in_silhouette: Reply From: Zylann

I never tried multitouch, but here is what I can guess from the documentation:

In the _input(event) callback, you can also get events of type InputEventScreenTouch. You would know an event is of this type by doing:

func _input(event):
    if event.type == InputEvent.SCREEN_TOUCH:
        # Do stuff with touch

These also contain an index property,
telling you what is the ID of the touch. So for example, if you touch with one finger you will receive an event with index 0, then if you touch with a second finger you will get a second event with index 1, etc. So you can tell them apart when further events of this type occur.