hello guys . i made this health script and i can’t seem to regan health every 5 seconds.
here is the script :
enter code here var MaxHealth : int = 200;
var CurrentHealth : int;
var GUIhealth: GUIText;
var tex4 : Texture ;
var healthRegan : float = 10.0;
function Start () {
CurrentHealth = MaxHealth;
}
function Update ( ) {
if ( CurrentHealth <= 0 ){
CharacterDeath ();
CurrentHealth += healthRegan * Time.deltaTime * 5; // <== here the part
healthRegan = MaxHealth ;
}
}
function CharacterDeath () {
Application.LoadLevel(Application.loadedLevel);
}
function OnGUI (){
GUIhealth.text = "Health"+ CurrentHealth.ToString();
if (CurrentHealth <= 80)
{
GUI.DrawTexture(Rect(0,0, Screen.width, Screen.height), tex4);
}
}
if my method sucks it will be nice if someone could rearanged =)