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.
- The second script is called
ChassisControls. It will make our tank move around. Create it in the
Scriptsfolder as well.
- 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
CharacterControllercomponent. 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 ...