- Home /
Touch interference
Hi everybody! I have done two scripts, one for camera controll and other for player controll, both use Touch structure. The first is tracking gestures and slides (primary Moved touch phase), the second is tracking ordinary taps. The problem is that touches interfere, and I have to somehow isolate them. I have some thoughts, e.g. create a structure, when if after TouchPhase.Began goes TouchPhase.Moved, camera controll script works, and if after TouchPhase.Began goes TouchPhase.Ended (tap), player controll script works. Unfortunately, I have no idea how organise all this. Is there any sugestions?
Answer by kromenak · Apr 27, 2012 at 10:09 PM
You should probably keep track of the time taken for a touch lifecycle to occur, as well as the distance moved by the touch. If a touch goes from Began to Ended within X seconds, and the position when it ended is greater than X distance from the start position, then consider it a tap.
For the swipe movement, you can also only register the swipe movement if the finger moves X units from its start position.
Using those sorts of tests for a swipe/tap, you should be able to accurately distinguish between the two. All the variables you need are in the Touch struct.
Your answer
Follow this Question
Related Questions
Swipe horizontally and hold finger down to move character? 1 Answer
Need Clarification on some Touch Struct Variables 1 Answer
Touch Phase ended not executing 1 Answer
Touch queue problem 0 Answers
Phase end not working on android 0 Answers