Build an amazing health bar in Unity.

Joseph Hibbs
2 min readOct 2, 2023

Creating a Health bar using sliders in unity, I decided to make a fancier looking one for fun. So first we need to create the UI Elements we need/want. Then inside our Slider’s Fill Area and Background we can set the rect transform all to 0, and the pixel per unit multiplier to 5 to give it a move boxish feel. We then proceed to create a text and make it an child of the handle’s handle game object and position it where we want it to be.

Now lets work on the manager, we have a script called IntSlider which will control our health. We need to acces the slider, the text we made under the handle, then we will create a health and max health.

In start I set the max health to 100 then have our health equal to our max health and call the method update slider text which assigns our slider value to our health then proceeds to assign that number as a string to our text.

To test out our health system I made a simple input for A and D to add and subtract 20 and to make sure it can not go above 100 or below 0, then it updates the slider text.

--

--