x


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?

more ▼

asked Jul 23 '11 at 04:17 PM

killerstud3 gravatar image

killerstud3
26 8 12 13

TornadoTwins?

Jul 23 '11 at 05:37 PM LegionIsTaken
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Jul 23 '11 at 07:09 PM

SilverTabby gravatar image

SilverTabby
1.9k 3 6 18

(comments are locked)
10|3000 characters needed characters left

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[i], 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 --;
    }
} 
more ▼

answered Jul 24 '11 at 04:48 AM

YikYikHeiHei gravatar image

YikYikHeiHei
311 8 9 13

Appreciate the script YikYikHeiHei.

May 03 '12 at 11:23 PM NorthernEagle
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x384
x205

asked: Jul 23 '11 at 04:17 PM

Seen: 1507 times

Last Updated: May 03 '12 at 11:23 PM