Hi! I have a problem with the lives in my game. It just goes straight to the game over screen, not subtracting from the lives. Sorry for the unformatted code, it isn’t copying and pasting right at the moment.
var Player : Transform;
static var CurrentScore : int = 0;
var MusicPrefab : Transform;
var GameOverSound : AudioClip;
var gameoverlevel : String ;
var ballHealth : BallHealth;
static var Restart = false;
function Start ()
{
CurrentScore = 0;
if (!GameObject.FindGameObjectWithTag("MM"))
{
var MM = Instantiate(MusicPrefab, transform.position, Quaternion.identity);
MM.name = MusicPrefab.name;
}
}
function OnGUI () {
GUI.Box ( new Rect (5 ,0, 80, 50), "Score: " + CurrentScore);
GUI.Box (new Rect ((Screen.width - 85) ,(Screen.height) - (Screen.height), 80, 50), "Lives:" + BallHealth.Lives);
}
function RestartLevel()
{
audio.clip = GameOverSound;
audio.pitch = 1;
audio.Play();
yield WaitForSeconds (audio.clip.length);
transform.position = Checkpoint.ReachedPoint;
ballHealth.BallColor();
ballHealth.Lives -= 1;
if (ballHealth.Lives == 0)
{
Restart = true;
CurrentScore = 0;
Application.LoadLevel(gameoverlevel);
ballHealth.Lives = 3;
Restart = false;
}