I’m currently testing multi-touch on different devices and have stumbled upon a problem. It seems that a couple of events gets lost during the frame. Probably because unity only checks the input at the beginning or end of each main loop frame.
On iOS this can be solved by changing the main loop type to Event Pump.
But on Android I can’t seem to find the documentation and was wondering if there is a similar way of solving this? Maybe someone have an idea of how to filter the invalid touches out of the list?
In my test it’s very important that the begin and end event doesn’t end up missing. This will result in a couple of touches being bound and still remaining active after you move your finger off screen.
To work around this issue on iOS, I wrote my own system of detecting the “phase” of a touch using some variables for keeping track of the phase manually. Since it’s all based around an Update() loop, it’s impossible for an event to get lost.
That’s not entirely true, at least for Android. On low FPS it is possible to miss events (the lower the fps the more likely it is). Especially if the frame rate drops below 15, it’s very likely that touch events will be missed unless you hold your finger for a long time on the screen
MikaMobile: Did you make the tracking from the xcode iOS touch functions. If you did, it wouldn’t help me at this moment. If you just made a Monobehavior in Unity that reads the current touch phases in the Update function and compared the phases against the previous ones, then it might help.
Tseng: At the current time the example is running steady at 40-45 fps. So I didn’t think that would be the problem, but I could be wrong. It seems to me that it can work perfectly for a long time and then all of a sudden it misses quite a few of them. No change in fps either which was a disappointment.
Maybe I have to be around 60 fps to get a really accurate touch reading?
On the iOS I could run the test without any complications at 25-30 fps too.
Is there such a great difference between android and iOS?
All in all it would be nice to at least get rid of all touches that missed the end phase cause they can really mess things up.
I think I am having the same problem on rare occasions. I will have a touch that will stick and never lift up until you tap with loads of different fingers at once, then it will be cleared for a while. I am not using touch phases but just checking the touchcount.
Yes, exactly. I will make a new test tomorrow and see if the phases just glitched that time. Hopefully the phases will be ended on some of them. But I will be surprised if they are.
TouchCount has a weird bug as far as i know… i came here to post about it… it seems it doesnt quite remove the touches after you removed you finger from the screen. example:
put finger on screen (touch = 1)
remove finger (touch still 1)
put finger on screen (touch = 2)
remove finger (touch goes to 1)
this happens more often when alot of fingers are used or in rapid succession, it seems as if android cant keep up and forgets about a finger.
I also have the same issue as victors. I am trying to trigger an event when I remove the finger but it just misses from time to time. When I touch again it usually catches the touch.end phase but then it misses again after a few tries. I will keep looking for an answer.
Are you using the UI introduced with 4.6? If so, check the event system object if the “Standalond input module” has the enable on mobile tick box active. If yes, turn it off.