hello, i have been following the race track tutorial, from unity by Morten Sommer, and making a racing game in my neighborhood 3d, addis ababa, Ethiopia.

i have set up the basics and it works perfectly. I added checkpoints and managed to pass through them and display the remaining checkpoints left,play a little pop sound at pick up. using info on this site.

what i couldn’t manage to do was having it switch level when the counter reach zero. i tried some of the solutions in here but didn’t seem to work.
Here is the code i’m using. i hope you guys will help and point me in the right direction. tnx

var skin:GUISkin;
var CheckPoint;
var PickUpSound: AudioClip;
var BackgroundMusicVolume : float = 0.6;


function OnTriggerEnter( other : Collider ) 
{    
		if (other.tag == "Finish") 
			{        
				CheckPoint -= 1;     
				AudioSource.PlayClipAtPoint(PickUpSound,Camera.main.transform.position);
				volume = BackgroundMusicVolume;
				Destroy(other.gameObject);
				
			}
}


function Awake() 
{
    CheckPoint = 3;
}


function OnGUI()
{
	GUI.skin = skin;
    GUI.Label( Rect (Screen.width - (Screen.width)/3.5,50, 300, 45),"CheckPoint = " + CheckPoint );
	
}

function update()
{
	if ( CheckPoint == 0) 
		{
			Application.LoadLevel("1");
		}
	
}

You need to capitalize Update(), because “update()” is not called by Unity (but “Update()” is).

Simplest solution- Application.LoadLevel() can be used with either a string or an int. If you call it with a string (like you are doing here), it will look for the level named “1” and try to load that, which of course will not work (unless you actually called your level that). What I prefer to do for this kind of thing, is call Application.LoadLevel(0), which is guaranteed to work (seeing as level 0 will always exist). Try that and see how far you get.

Hope this helps!

As I promised. I added the credits and you can download the game :

http://min.us/lP0Qd6GitbeAG