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");
}
}