Health Bar Issues

Hey I was wondering ways to make a textured health bar easily. Also I was wanting to find out how to hide the health bar if I don’t want it shown. Thanks

What I would do is use GUI.Box. Then feed the health value into the length and/or width of the rectangle (scale as needed). You can use a custom texture by passing in a GUIContent Object with your health bar texture on it. You can also pass your health as a string to have it displayed on the box.

This is what I’m using for my game’s health bar, and I think it is all you need for yours.

Hope this helped

It can make health bar easily…

var yourHealth = 100.0;
var yourMaxHealth = 100.0;

function Start ()
{
    yourHealth = yourMaxHealth;
}

function OnGUI ()
{
    GUI.HorizontalScrollbar(Rect (0,40,300,20), 0, yourHealth,0, yourMaxHealth);
}