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:
- To start this off, create a new script and name it
- 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;
- Next, we will make use of the
Update function. We start out by creating a variable to store the ship's current rotation. ...