Chapter 5. Preparing for Gameplay

Now that the gnome and the rope have both been created, it’s time to set up the system that lets the user provide input to the game.

We’ll do this in two parts: first, we’ll add the script that makes the gnome swing from side to side when the phone is tilted. After that, we’ll add the buttons that lengthen and retract the rope.

Once that’s done, we’ll begin implementing the code that drives the game itself: first, we’ll do a bunch of setup work that the gnome will end up using, and then we’ll implement a manager object that keeps track of some important game states.

Input

Because we’re now at the point where we need to get input from the device, it’s time to make sure that the Unity Editor can receive input. Without this, the only way to test the game is to build the game and install it on a device, which can take a while. Unity’s all about being able to rapidly test your changes, and waiting for a build to finish will slow you down a lot.

Unity Remote

To allow quickly providing input to the Unity Editor, Unity has an app on the App Store called the Unity Remote. Unity Remote connects to the Unity Editor through your phone’s cable; when the game is playing in the Editor, the phone displays a copy of what’s being shown in the Game window, and sends back all touch and sensor information to your script. This allows you to test the game without having to do a build—all you need to do is launch the app on your phone, and play the game as if it were ...

Get Mobile Game Development with Unity now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.