Moving the player
The game, as it currently stands, features an environment with collision data and a multipart player object that interacts and responds to this environment. The player, however, cannot yet be controlled. We'll correct this situation now as we explore controller functionality further by writing and implementing a player control script.
Writing the movement script
The user will have two main input mechanics; namely, movement (walking left and right) and jumping. This input will be read using CrossPlatformInputManager, which is a native Unity package that was imported during the project creation phase. Let's take a look:
- Open the Assets | Standard Assets | CrossPlatformInput | Prefabs folder and drag and drop the MobileTiltControlRig prefab into the scene. This prefab lets you read input data across a range of devices, mapping directly to the horizontal and vertical axes that we've already seen in previous chapters.
- Create a new C# script...