Let’s go over the implementation of a simple charge meter for the speed boost power-up in the space shooter.

I previously went through the implementation of the speed boost power-up in this article and I also went through adding UI in this article. The base for the thrusters was add here.

Add an Image object called to the UI which will be the background for the charge meter. Add another Image object as a child of the first image and call it fill. Set image type tio filled. Also a Text object as a child of the first image.

Open the script and a private Image for the fill image. Also add a public function that will handle the fill amount:

Open the script and add two floats for the thruster charge:

Amend the function to no longer be a coroutine and instead cool down by reducing the charge with Time.deltaTime:

In the power-up switch statement reset the charge based on max charge:

Amended the to allow no longer be unlimited and get disabled if there is no charge left. You can also call the from here or from if you prefer:

Lastly, add the fill image to the UIManager script in the inspector:

Final result:

Good luck!

Unity / C# Game developer