I have a level that requires 10 points to win. Right now, I can get 10 points, but the next level does not load. Can anyone tell me how to script a level to load upon completion of the score reaching 10? All help is greatly appreciated. Thank you!
Shawn
Updated with Shawns code in comment reply:
I am lost, here is my code:
var score = 0;
function Update()
{
if (score > 4)
{
Application.LoadLevel(1);
}
}
And this is my score script:
var cam : GameObject;
var Win : GameObject;
var Lose : GameObject;
var score = 1;
function AddToScore()
{
++score;
guiText.text = "Score: " + score.ToString();
}
function SubtractFromScore()
{
--score;
guiText.text = "Score: " + score.ToString();
}
You can do something like this if your levels are next to each other by index:
// if score is 10 or more
if (score >= 10)
{
// if we aren't at the last level
if (Application.loadedLevel != lastLevel)
{
// then load the next level
Application.LoadLevel(Application.loadedLevel + 1);
}
else
{
// Game completed!
}
}
I am far from an expert. I am new to programming and still trying to figure out how to get my scores to carry over. But i found a cheating quick fix. this will do till you find a better way.