- Home /
Detect if finger lifted off screen
Hello once more..Now I have a really simple question. Here is my code:
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
{
var touchDeltaPosition:Vector2 = Input.GetTouch(0).deltaPosition;
if( touchDeltaPosition.x <-10)
{
transform.position.z += 3;
}
It detects finger movement when I touch the screen, but I need to detect swipe only when finger lifts off the screen. Any sugestions?
Answer by aldonaletto · Sep 15, 2013 at 04:18 AM
Take a look at TouchPhase.Ended: it tells when the touch has finished.
please take a look at my script. When should i use a TouchPhase.Ended? I cannot understand where to use it.
:/
Put another if statement following your moved routine
if (Input.GetTouch(0).phase == TouchPhase.$$anonymous$$oved) { }
if (Input.GetTouch(0).phase == TouchPhase.Ended) { }
Well done. Throw round a couple of thumbs up in celebration :P
Your answer
Follow this Question
Related Questions
Touch Input positions are different on iOS and Android? 2 Answers
mouse input to touch input help please 0 Answers
Swipe menu, problem! 0 Answers
Android touches wrong after using the application at least once 0 Answers
Swipe and Joystick Together on Mobile 0 Answers