Adding Thrusters: Speed Modifiers in Unity

Tristen Hart
2 min readSep 16, 2023

--

Thanks to Unity, I have been able to comfortably implement smooth movement to the player for my space shooter project. What I’m wanting to do now is add an extra control for my player, giving you the ability to move faster with the “Shift” key held.

Having one uniform speed setting (and a speed powerup) is fine enough, but giving the player an option to modify the players speed at will gives you a much greater sense of control, and better control equals fun.

Adding a thruster control is very similar mechanically to having a speed boost powerup, where you can either modify the speed variable or change the movement equation, adding a temporary multiplier variable into it. What I chose to do is the latter option.

if(_isSpeedBoostActive == false)
{
transform.Translate((_speed + _shiftSpeed) * Time.deltaTime * direction);
}
else
{
transform.Translate((_boostSpeed + _shiftSpeed) * Time.deltaTime * direction);
}

The only new concept introduced through this is the mechanics of toggling the thruster on and off when the key is held down. This is done through using GetKey over the usual GetKeyDown. Here’s what happens with my _shiftSpeed variable:

Final Tip: All code is read by Unity from top to bottom, starting at the top of the method. I made sure to keep this on the very top of my movement calculating method to ensure that the modifier is actually read before the actual move is performed.

--

--