Slide on screen to slide in game

Viewed 37

how can i detect when player slide the screen down and let him to slide? i tried to do somthing like this:

    if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)

        startTouchPosition = Input.GetTouch(0).position;

    if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
    {
        endTouchPosition = Input.GetTouch(0).position;

        if (endTouchPosition.y < startTouchPosition.y)
            preformSlide();
            Invoke("StopSlide", 1);
    }
0 Answers
Related