- Home /
Realistic Health Bar
Hey,
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?
if you show atleast how it looks we can give some suggestions, because there are a lot of ways to do a health bar
Answer by Piflik · May 10, 2012 at 04:54 PM
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.
Answer by Meater6 · May 31, 2012 at 07:01 AM
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.
It ended up pretty well using 2 GUI textures, one on top and another underneath changing in size.
Answer by Wolfram · Jun 03, 2012 at 10:48 AM
...aand another link to the fifth-most voted questin on Unity Answers... ;-)
http://answers.unity3d.com/questions/14770/creating-a-circular-progressbar-timer.html