Ive created a game over screen, but whenever the lives reach 0 the game continues to play.
var Life = 3;
function Loselife()
{
Life --;
}
function OnGUI () {
// Make a background box
GUI.Box (Rect (10,10,100,25), "Life: "+Life);
}
function update()
{
if(Life == 0){Application.LoadLevel ("Lose");
}
}
My script to call the LoseLife function works properly as The number of lives decrease correctly, but when it reaches 0 it doesnt move to the Lose scene.
Here is the other script:
var Life : Life;
function OnCollisionEnter(collision : Collision){
iTween.FadeTo(gameObject,{"alpha":0, "onComplete":"destroy"});
Life.Loselife();
GetComponent(CapsuleCollider).enabled = false;
}
function destroy():void{
Destroy(gameObject);
}