health system

I am trying to make a health system with 3 lives and 3 GUI textures to say how many live are left. i want it so that whenever you get hit by a “fireball” you lose one life but i have no idea where to start can somebody please help me?

The 3d platformer tutorial has everything you will ever need to know from cameras, a health system, enemy AI, and more.

If you feel more like videos, you can try the TornadoTwin’s unity video series on youtube.

It have 3 lives and 3 GUI textures and hit by a “fireball” lost a life.

var lives = 3;
var livesTexture : Texture2D[];
var livesTextureSize = 30;

function OnGUI ()
{
    var livesTextureRect = Rect(10,5,livesTextureSize,livesTextureSize);
    for (var i : int = 0; i < lives; i++)
    {
        GUI.DrawTexture(livesTextureRect,livesTexture*, ScaleMode.ScaleToFit, true, 0.0f);*

livesTextureRect.x += livesTextureSize + 10;
}
}
function OnCollisionEnter(collision : Collision)
{
if (collision.collider.tag == “fireball”)
{
if (lives-1 >= 0)
livesTexture[lives-1] = null;
lives --;
}
}