Hello! I am trying to make a enemy health bar that displays the amount of health the enemy has; after I kill it, the bar should display 0. I need some help to display this. My script won’t work. Could you please help me write a script that displays this. Here is my current script:
#pragma strict
function OnGUI()
{
var box = GUI.Box(Rect(20,20,200,30),"First Enemy Health: " + EnemyHealth.Health);
var boxTwo = GUI.Box(Rect(20,20,200,30),"First Enemy Health: 0");
return box;
if (EnemyHealth.Health <= 0)
{
return boxTwo;
}
}
function ApplyDammage(TheDammage :int)
{
EnemyHealth.Health -= TheDammage;
}
This script calls from another script called Enemy Health. Here is this script:
#pragma strict
static var Health = 100;
function Update () {
if (Health <= 0)
{
Destroy (gameObject);
}
}
function ApplyDammage(TheDammage :int)
{
Health -= TheDammage;
}
Anyone, can you please help me.