O'Reilly logo

Unity Android Game Development by Example Beginner's Guide by Thomas Finnegan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – steering the space ship

To steer our ship, we will need to create a single script and apply it to our ship:

  1. To start this off, create a new script and name it TiltSteering.
  2. As with all of our other scripts, we will begin this one with a few variables. The first two variables control the speed with which the ship will rotate as the device is tilted. The second two are going to be used to limit the rotation of the ship. These will determine how tight a circle the player's ship can turn in.
    public float horizRotateSpeed = 7f;
    public float vertRotateSpeed = 3f;
    
    public float horizMax = 60f;
    public float vertMax = 45f;
  3. Next, we will make use of the Update function. We start out by creating a variable to store the ship's current rotation. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required