For today’s article, I’ll be going over how I add speed boost to the player ship.
Unity Editor Setup
In the Unity Editor, I created an empty game object named
Thruster as a child object of the
Player. Next, I added an Animator component and placed in the image frames to create the boost animation.
Update() function of the
Player script, I moved the logic into a private helper function called
CalculateBoost() to keep calculating movement and boosting the ship separate.
CalculateMovement() function, I multiply the
speed variable with a
currentBoostMultiplier variable. If
currentBoostMultiplier is set to 1, the ship will move at normal speeds. If
currentBoostMultiplier is set to a number greater than 1 (e.g. 2), then the ship will be moving at twice its normal speed.
To see more of the code, please visit https://github.com/hlimbo/Space-Shooter-Tutorial
Thanks for reading :)