-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Unity Android Game Development by Example Beginner's Guide
By :
We will only be making a single script in this section. It will move the tank in a similar manner to the ChassisControls script we created in the last chapter. The difference is, we won't have to hold down a button for the boost to work. Let's get to it.
Start by creating a new script and calling it TurboBoost.
To start the script off, we need four variables. The first is a reference to CharacterController. We need this for movement. The second is how fast we will be moving while boosting. The third is how long, in seconds, we will be boosting. The last is used internally for whether or not we can boost and when we should stop.
public CharacterController controller; public float boostSpeed = 50; public float boostLength = 5; public float startTime = -1;
The next bit of code returns to our good friend, the OnGUI function. Here we are just drawing a button on the screen, the same as we did several times before. If the button is pressed, it calls the StartBoost...
Change the font size
Change margin width
Change background colour