- Home /
WaitForSeconds does not work
Here is my coroutine :
IEnumerator SyncLevelCoroutine(LevelData a_level)
{
Network.SetSendingEnabled(0, false);
Network.isMessageQueueRunning = false;
Network.SetLevelPrefix(1);
Application.LoadLevel(a_level.m_szLevelName);
while(m_nStatus == EStatus.eSynchronizing)
{
yield return new WaitForSeconds(0.1f);
}
Network.isMessageQueueRunning = true;
Network.SetSendingEnabled(0, true);
if(Network.isServer)
{
SetReady();
}
else
{
networkView.RPC("SetReady", RPCMode.Server);
}
}
and here is the call of the coroutine :
StartCoroutine("SyncLevelCoroutine", level);
The coroutine is stopped in the WaitForSeconds statement. I have tried to put a Debug Log before this line, but the log is shown only once. Any log after the while loop is not shown. If I replace "yield return new WaitForSeconds(0.1f)" by "yield return null", it works. Any idea why WaitForSeconds lasts an eternity?
this guy had a similar problem. http://answers.unity3d.com/questions/60725/waitforseconds-problem-with-unity-pro.html
Check your timescale in your project settings. $$anonymous$$aybe thats the issue.
well thank you, that was that... I m feeling so dumb right now...
Your answer
![](https://koobas.hobune.stream/wayback/20220613094339im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
WaitForSeconds Not Working 4 Answers
Problem with coroutine 2 Answers
What is the best method for setting up a variable wait time in a coroutine? 1 Answer
Why isn't my simple coroutine working? (and how can I make it infinite?) 2 Answers
my script is broken again(enemy refuses to stop seeing me) 1 Answer