My GameDevHQ Journey Day 40: Adding the Thrusters Feature

Nnamdi Azikiwe
2 min readFeb 17, 2023

--

Objective: Add Thrusters feature to Galaxy Shooter 2D

Photo by Lawrence Hookham on Unsplash

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.

Thrusters are go!!!

So how did we do it? It all takes place in the Player script. First we added a SerializedField float variable named _thrusters.

A variable added for the thrusters value.

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.

Testing if the Left Shift key is pressed in the Update method.

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.

Just by adding the

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…

--

--

Nnamdi Azikiwe

Join me on a 90+ day journey in Game Development with Unity 3D using C#.