My GameDevHQ Journey Day 40: Adding the Thrusters Feature
Objective: Add Thrusters feature to Galaxy Shooter 2D
So far we have been using Unity to develop a game named Galaxy Shooter 2D (aka GS2D.) The next series of articles will focus on adding features to the game. Next we will add Thrusters to increase the player’s speed when the “Left Shift” key is held down. It resets to normal when it is released.
So how did we do it? It all takes place in the Player script. First we added a SerializedField float variable named _thrusters.
Next we add a few lines in the Update method. Since Update is called every frame of the game, what we are doing happens every frame. By testing if the Left Shift key is pressed we change _thrusters rapidly. _Thrusters is 3.0f when the Left Shift is down and 1.0f when the Left Shift key is up.
The next modification we made to the Player script is in the CalculateMovement method. There we added _thrusters as a parameter when we call the transform.Translate method.
That makes our player move three times as fast when the Left Shift key is down. Tomorrow on our GameDevHQ Journey we will cover how to add visual indicators of shield strength. Until then…