Im having issues with GUI texture health bar, currently the player is receiving damage and when health reaches 0 the level restarts, but the GUI textures do not change. The health bar is represented by 3 different textures but it displays only one (full health) even when damage is being applied.
here is my code, can someone please help me with this one, thanks
static var health:int=4;
var health3: Texture2D;
var health2: Texture2D;
var health1: Texture2D;
function OnCollisionEnter(hit: Collision){
if(hit.gameObject.collider){
health = health - 1;
}
}
function Update () {
if(health == 0)
Application.LoadLevel("level01");
var health=GameObject.Find("health");
if(health==3){
guiTexture.texture = health3;
}
if(health==2){
guiTexture.texture = health2;
}
}