Phase 1: Thrusters

Simon Leen
2 min readJun 15, 2021

Objective: Add thruster mechanics to the player.

So in order to get thrusters working we need to be able to adjust the speed. Like we did for the speed powerup, we will set a serializable private float to use as a thruster speed multiplier.

As an addition to making the player faster while thrusters are on, some visual feedback would be a nice touch. For this we set a serializable private game object for the thruster attached to the player and assign it in the inspector.

Thruster speed multiplier and game object

Next within the update method, we run two if statements, one to check if the left shift is pressed and the other if the left shift key is released. Each option calls to its specified method. Pressed calls the thrusters activate and released calls thrusters deactivate.

Activate and Deactivate methods

As you can see above, the logic between both is similar. In activate we multiply player speed by the thruster speed multiplier and deactivate divides. We set a Vector3 scaler variable and on activate set the thruster object attached to the player to the larger scaler and on deactivate, set the scale back. While scaling the object, the position slightly moves so we create a Vector3 thruster position and adjust the y position of the transform for cleaner presentation.

Thrusters activated and deactivated

In the next post, we will look more at the players shield behaviour.

--

--