- Home /
Question by
e_m_l_i_a_n_o · Aug 04, 2011 at 03:01 AM ·
changelevel
Chage level Whith time
Hello can some one help me, I am devloping a game in which you have to visit diferent places in a ''X'' amount of time I am using this code but I don't know why it dosen work...
function Start(){
yield WaitForSeconds(30);
Application.LoadLevel(1);
yield return new WaitForSeconds(30);
Application.LoadLevel(2);
}
Comment
well, what DOES it do? Any errors? Greetz, $$anonymous$$y.
In this code you wait 30 seconds, go to next scene and then wait another 30 seconds to go to next scene?
Answer by GuyTidhar · Aug 04, 2011 at 07:12 AM
You should call a coroutine in which you will yield the processing of this script for the rest of the processing of your code. try doing the following:
function Start()
{
StartCoroutine("TimedLeveling");
}
function TimedLeveling()
{
yield WaitForSeconds(30);
Application.LoadLevel(1);
yield WaitForSeconds(30);
Application.LoadLevel(2);
}