Time for action – controlling the chassis

A normal tank rotates in place, and it can easily move forward and back. We will make our tank do this with the creation of a single script.

  1. The second script is called ChassisControls. It will make our tank move around. Create it in the Scripts folder as well.
  2. The first three lines of the script define the variables the tank will need to move around. We will also be able to change them in the Inspector window, in case our tank is too fast or too slow. The first line defines a variable that holds a connection to a CharacterController component. This component will easily move the tank around, but will allow it to be stopped by walls and other colliders. The next two lines of code define how fast we move ...

Get Unity Android Game Development by Example Beginner's Guide 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.