- Home /
The waitforseconds does not run?
function Awake () {
Debug.Log("starting");
wait();
}
function wait() {
Debug.Log("loading1");
yield WaitForSeconds(20);
Debug.Log("loading2");
Application.LoadLevel ("scene2");
//StartCoroutine( LoadLevel("scene2"))
}
Where does the code seem to be stop? Are you receiving all you Debug.Log messages in the console?
starting from a menu screen it goes starting,loading1,loading2 (goes in main game then goes to menu start) starting,loading1 (no more response)
Just to see if it changes the behavior, could you move this from the call to the wait() function out of Awake() and into Start().
like this? (if not please explain) no change
function Start(){
Debug.Log("starting");
wait();
}
function Awake () {
//Debug.Log("starting");
//wait();
}
function wait() {
Debug.Log("loading1");
yield WaitForSeconds(20);
Debug.Log("loading2");
Application.LoadLevel ("scene2");
//StartCoroutine( LoadLevel("scene2"))
}
Answer by perchik · Sep 19, 2013 at 07:47 PM
Are you writing C# or Javascript?
If it's c# you can't just yield waitforseconds from any function, you have to call that function as a Coroutine, ie StartCoroutine(wait());
Your answer
Follow this Question
Related Questions
Best way to wait for event inside Coroutine? 3 Answers
Waiting for input using yield and coroutines 1 Answer
Yield to wait for delegate call 1 Answer
Problem with yield waitForSeconds in for loop 0 Answers
Why is my delay not working? 2 Answers