Hey I tried to make a Health Bar, like the one in Tornado Twins video. (I also searched for other questions in here but no one matched my problem)
Anyway the thing is I got 3 lives and I want to loose 1 everytime I die like falling off the platform. I made some texture for the GUI, so 1 heart, 2 hearts, 3 hearts. But when I start I start at 2 lives (2 hearts) Instead of what should 3 and I dont loose any when I fall down to my “death” It looks like this
private var Dead = false;
function OnControllerColliderHit(hit: ControllerColliderHit)
{
if(hit.gameObject.tag == "fallout")
{
Dead = true;
//subtract life here
HealthControl.LIVES -= 1;
}
}
function LateUpdate()
{
if(Dead)
{
transform.position = Vector3 (0,4,0);
gameObject.Find("Main Camera").transform.position = Vector3(0,4,-10);
Dead = false;
}
}
@script RequireComponent(CharacterController)
This is in one of my scripts
var health1 : Texture2D; //one life left
var health2 : Texture2D; //two lives left
var health3 : Texture2D; //full health
static var LIVES = 3;
function Update ()
{
switch(LIVES)
{
case 3:
guiTexture.texture = health3;
case 2:
guiTexture.texture = health2;
break;
case 3:
guiTexture.texture = health1;
break;
case 0:
//gameover script here
break;
}
And this is in the other
And here is how I put up the heart pictures

Any ideas? cheers