2D Galaxy Shooter:Scaling Bar HUD
Scaling Bar HUD to the UI that will limit the use of the thrusters…….
Here there is another feature which is supplement to Simple Thruster , now we have the Scaling Bar HUD i.e, Slider with values filled-up with default max- value of 10 and min-value of 0.
This Scaling Bar is created on canvas using slider as well as text shown below:
Slider has been reference in script UIManager.cs ,
[SerializeField]
private Slider _slider;
UIManager.cs script file has a public method UpdateThrusterScale communicated from the Player.cs Script file.
UpdateThrusterScale(float elapsedTime, float thrusterScale) having parameters elasptedTime default set to 0 and thrusterScale default set to 10 with default Scale Bar set to max-value of 10 with color green.
When Player press the Left Shift Key , it activate the thruster as we have seen in last article and when release, it will deactivate the thruster..
Here when Player press the Left Shift Key , its keep boost the speed of the Player with Scale Bar color Green (max-value10) as default and as player keep pressing Left shift key it keep changing color of Scale Bar as time-elapsed and finally color of Scale Bar changed to RED (min-value 0), its makes thruster deactivate and cannot be activated until till it will regain back to full Scale Bar to Green.
This all above is explained in logic below when call the method UpdateThrusterScale() in the same update frame where Player movement method is called…
This way we have implemented new feature for Thruster: Scaling Bar HUB
- Having UI element to visualize the charge element of thrusters.
- Cool Down System required before restarting it again..