Realistic Health Bar


I am trying to create a health bar, but adjusting the width of the GUI texture is not realistic enough as it stretches the sides of the texture.

What I want to make out is having the color of a box fill and empty.
How would I go about doing this?

You could draw a box above your health bar and instead of shrinking the health bar, you expand the one on top. This obviously only works, if you want the ‘background’ of your health bar to be a solid color.

There is a another way, but it’s not as effective as using a GUI texture. You can use the built in GUI class, and use the GUI.BeginGroup function to clip textures. I have the same question, but I thought I might as well tell you how I was able to clip a health bar.

…aand another link to the fifth-most voted questin on Unity Answers… :wink: