Implementing a gesture

Another type of input that you'll find in mobile games is that of a swipe. This will allow 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 put that in, instead of our previous movement system:

  1. First, 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 pixel space)")]    public float minSwipeDistance = 2f;    /// <summary> 

Get Unity 2017 Mobile Game Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.