1
\$\begingroup\$

This is a code that I am working on for a space shooter. Part of it works and my score does increase by 7 every second while being loaded into a GUI box, but my script does not load my scene when the number reaches 1000. I have made sure that my scene is a part of my build settings and I have tried some fixes but it doesn't load even though I don't get any sort of error. Any Ideas?

#pragma strict
function Start(){
InvokeRepeating("EachSecond",1.0,1.0);
}

var score: int = 0;
var addscore = 7;

function EachSecond()
{
score=score+addscore;
}

function OnGUI(){
GUI.Box(Rect(1000,10,100,25), score.ToString());
}
function WinningScore()
{
     if (score >= 1000 )
     {
          Application.LoadLevel("Win");
     }
  }
\$\endgroup\$
  • \$\begingroup\$ winingScore function is not been called anywhere :) \$\endgroup\$ – Adnan Nazir Nov 12 '15 at 15:02
2
\$\begingroup\$

You have to call the WinningScore function in the update or in the EachSecond method after you increase your score.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.