[solved] Simultaneous touches


I’m trying to use multitouch for a concept game I’m working on. The idea is to control a car (in top view) using 2 fingers for rotating left/right. This is a similar mechanic to photo album apps. I noticed that if I touch one finger and then touch the second it works. If I touch both finger simultaneously GDevelop recognize only a single touch, so it doesn’t work.

Anything I could check or do? Is this supported in GDevelop at all?

Multi touch is fully supported, it just depends on your setup and which events you use. For more detail check out the multitouch example included in the engine to see how it is set up.

I keep this image close.
When a touch start, you create a detection object and set the ID variable to the last touch ID
Whenever a touch ends, delete it
The touchs that stay active take the position of the respetive touches (Checking ID)

Then you can use events for Marker colliding with “X” then “Y”

Put the A new touch has started into a while…repeat loop, like @oscuridad666 did for the touch ended.

I have no problem with multitouching, but it seems if the touches happen at the exact same time then GDevelop only registers one touch. I was able to also verify this by looking at the LastTouchId() value. It shows 0 instead of 1 (for 2 touch points). If I touch the screen with 2 fingers but with a small delay then GDevelop is able to detect both touches.
Other than that issue (no simultaneous touches) everything works fine.

No, that’s the id of first touch you’re processing, not the last touch or touch count. If you loop like I said earlier, you will get all the touches. LastTouchId() appears to work like a stack popper, where the stack holds all the current touch ids.

If I do this:

and touch the screen with 2 fingers simultaneously, debug.text get “01” added every single time. This is the first touch id (“0”) and the second touch id (“1”).

If I touch 3 fingers simultaneously, it adds “012” to debug.text.

If I do 2 fingers, fraction of a second delay, then 1 finger, I get “010”.

If I just touch with one finger, it just adds “0” to debug.text.

You’ll be retrieving or processing the touches incorrectly, or your device doesn’t have multitouch.

You are right, I tested the code using a while loop and it works!
GDevelop is able to identify both touches now.
Thank you oscuridad666 and MrMen.