Adding thrusters to our Space Shooter!

Jay Barnes
2 min readNov 16, 2023

--

Today’s goal is to add a thruster system, or built in speed boost to our 2D space shooter, by holding down the left shift button.

To get started we’ll find our movement method and break down exactly what we’re trying to accomplish using psuedo code.

Our first step is to check for if the left shift button is being held down. To do so we’ll use Input.GetKey, which returns true when the player holds down a specific keycode, then we’ll pass in the left shift key as the KeyCode we’re checking for.

if (Input.GetKey(KeyCode.LeftShift)) {
//increase speed
}

Currently we move our player using transform.Translate which takes vertical and horizontal inputs multiplied by a speed variable and Time.deltaTime to make it frame rate independent. We can easily increase our speed by taking that same code and multiplying our speed variable by 2.

Our thrusters are up and runnin! Instead of hardcoding the value into our formula, we can instroduce a new variable that can be modified in the inspector to control the value of our thrust speed.

Now, if we replace the hardcoded value in our movement code, we can modify our thrust variable in the inspector to control the speed and feel of our game until we achieve the desired effect.

And that is how I introduced a thruster system into my 2D space shooter game.

--

--