Health control (437554)

hi, this is my script for Health Control, I want to end the game, when I don’t have more any lives,
but it don’t happend, what I did wrong?

var health1 : Texture2D;
var health2 : Texture2D;
var health3 : Texture2D;

static var LIVES = 3;

function Update () 
{
		switch(LIVES)
		{
			case 3:
				guiTexture.texture = health3;
			break;
			
			case 2:
				guiTexture.texture = health2;
			break;
			
			case 1:
				guiTexture.texture = health1;
			break;
			
			case 0:
					if(LIVES == 0){
						Application.Quit();}
			break;
		}
}

I am using JS…

According to the script reference for Application.Quit:
Quits the player application. Quit is ignored in the editor or the web player.
So it won’t do anything when you test your game with the Play button (you can try Build Run).

Btw, the ‘if (LIVES == 0)’ check isn’t necessary, switch already took care of that. So:

			case 0:
				Application.Quit();
			break;

thanks

but it isn’t work

Are you subtracting your LIVES somewhere? Based on the code you have, LIVES will forever be stuck on 3 unless you have something in another code that changes that.

You could always add

Debug.Log("Lives = " + LIVES);

to the Update function to see if anything is changing.