Creating HUD that Updates Speed

Niraj Karki
2 min readMay 29, 2021


Day 38- Making 2D Space Shooter Game

Objective: Make our player move faster when pressing Shift key while the HUD bar decreases and with time fills itself.

Create a Image in canvas and set its color to the one you want your HUD bar to have.

It is better to create a background for the created Image and set its alpha to low value to give transparent background giving the effect of vessel.

Declare variables to store the maximum speed boost time, current speed boost time and Player script.

Store the Player script in the declared player variable.

Create two public variable to set the speed boost to true and false in the Player script.

Now set the condition so that when the speed boost is true and player holds shift key when moving, he gets a speed boost; boost being the _speedMultiplier variable.

Also set the thruster to active when the speed is being boosted to give the effect of speed increasing due to thrusters.

Finally update the HUD bar every time player holds shift and remaining time is greater than 0.

We also need to refill the thruster so create a condition to slowly fill the HUD bar overtime until the remaining time is equal to the maximum speed boost time.



Niraj Karki