I have a want a healthbar in my game but i dont now how to make it can you plz help me. the health script is:
var health = 100.0; var dieDuration = 0;
function ApplyDamage( amount : float ) {
health -= amount;
if (health < 1) {
Die();
} else {
// <- (play "hurt" animation & sound here)
}
}
function Die() {
// <- (play "die" animation & sound)
yield WaitForSeconds( dieDuration );
Application.LoadLevel(Application.loadedLevel);
}
and the damage script is:
var damage = 10;
function OnTriggerEnter (hit : Collider) {
if(hit.gameObject){
hit.gameObject.BroadcastMessage("ApplyDamage",
damage,
SendMessageOptions.DontRequireReceiver);
}
}
I want a green healthbar that change to yellow when my character have 50 health and that change to red when the character have 15 health left.
Thx // Dummy7307