Implementing a gesture
Another type of input that you’ll find in mobile games is that of a swipe, such as in Kiloo’s Subway Surfers. This allows us to use the general movement of the touch to dictate a direction for us to move in. This is usually used to have our players jump from one position to another or move quickly in a certain direction. So, we’ll go ahead and implement that using the following steps, instead of our previous movement system:
- In the
PlayerBehaviour
script, go ahead and add some new variables for us to work with:[Header("Swipe Properties")] [Tooltip("How far will the player move upon swiping")] public float swipeMove = 2f; [Tooltip("How far must the player swipe before we will execute the action (in inches)")] public float minSwipeDistance = 0.25f; /// <summary> /// Used to hold the value that converts /// minSwipeDistance to pixels /// </summary> private float minSwipeDistancePixels...