So my coroutine should play animation then wait then load new scene it looks like this
IEnumerator LoadLevel(int levelIndex)
{
Animator.SetTrigger("trigger") ;
yield return new WaitForSeconds(time);
SceneManager.LoadScene(levelIndex);
}
But what it does is it first waits then loads new scene and after that it plays the animation and I dont know how to play it in correct order. Please help.
#Coroutine is not playing properly in order
1 messages · Page 1 of 1 (latest)
Increase the value of the time variable
Thats for some reason not working neither it just waits for longer period of time and then it does the same
It waits, load new scene, play animation and I want it to play animation, wait, load new scene
You want LoadSceneAsync
You want to load the new scene, then play your animation and wait, and then after some amount of time you can then make the transition to the new scene
I don't understand what should i do
Just gave you the answer, you'll have to figure it out from there
Ok guys I have no clue what I did but it's working. Thanks guys for your effort in helping me. 🙂
Were you calling it using the StartCoroutine() function before?
Yep
hey just saw this, have u tried WaitUntil() ?
with a Lamda expression you can tell your coroutine to wait for a specific method or value, or you could just try async functions instead of using the IEnumerator
(See https://docs.unity3d.com/ScriptReference/WaitUntil.html)
Looks cool thanks man.
Shouldn't use Async in unity as it's not fully supported and unity is single threaded anyways