- Home /
Differentiating between a tap from a swipe on Android
I'm trying to differentiate a tap from a swipe. I have it in my game so if you tap the screen, the character on the screen jumps, and if you swipe down, he slides/ducks. The problem is, I can't seem to figure out how to differentiate a tap from a swipe. The character will always jump, because the jump code is simply:
if (Input.touchCount > 0) { Jump(); }
I've seen some people ask the same question, and some people answer "check time.deltaTime and see if it has moved or stayed still", this seems like a good way to do it, but I'm not sure how to do it.
Hi, did you find out how to differentiate a touch and a swipe ? I'm having the same problem. i tried to solve it via
-TouchPhase.Began (get current position)
-TouchPhase.$$anonymous$$oved (check current position with position from began ->if difference is big then it is a swipe and no tap )
-TouchPhase.Ended (check current position with position from began ->if difference too is small then it is a tap and no swipe)
$$anonymous$$y Problem: tap is recognized too late, when my finger leaves the screen. This is because of TouchPhase.Ended. I'm looking for another solution.
Answer by callen · Nov 25, 2015 at 09:16 PM
I think all you need is to become familiar with the Touch class, and Input.Touches
The TouchPhase and deltaPosition should be all you need, but the class has more data you may be able to utilize as well.
Your answer
Follow this Question
Related Questions
IOS Swipe Gesture 0 Answers
UI Buttons not always working on Android? 0 Answers
Simultaneous Android and iOS development 1 Answer
Device Auto-Rotation 1 Answer
Ampersand in application name 4 Answers