Another type of input that mobile has, that PC doesn't, is the accelerometer. This allows you to move as the phone is tilted. The most popular example of this is likely the movement of the player in games such as Lima Sky's Doodle Jump. To do something similar, we can retrieve the acceleration of our device using the Input.acceleration property:
- First, we may want to allow our designers to set whether they want to use this mode, or the ScreenTouch we used previously. With that in mind, let's create a new enum with the possible values to place in the PlayerBehaviour script above the Swipe Properties header:
public enum MobileHorizMovement
{
Accelerometer,
ScreenTouch
}
public MobileHorizMovement horizMovement = MobileHorizMovement.Accelerometer;
This gives us a property called horizMovement and the two possibilities that it can have...