- Home /
Moving Coroutines To One Method
Hi, I have 3 different coroutine methods which I am calling them in the update section I was wondering if I can set them in one method and call them with their return type and value. I want to learn coding and I have never used return type or return value properly.
IEnumerator EndScene (){ yield return new WaitForSeconds(8.0f); _GameMan.LoadNextScene(); } IEnumerator EndParticle (){ yield return new WaitForSeconds(.5f); endSceneParticle.Play(); } IEnumerator FadeWait (){ yield return new WaitForSeconds(6.0f); animator.SetTrigger("Fade_out"); }
Answer by WarmedxMints · Feb 27, 2019 at 03:49 PM
They aren't returning anything to check. However, going by the names, it looks like you only need one Coroutine.
private IEnumerator EndScene()
{
yield return new WaitForSeconds(.5f);
endSceneParticle.Play();
yield return new WaitForSeconds(5.5f);
animator.SetTrigger("Fade_out");
yield return new WaitForSeconds(2f);
_GameMan.LoadNextScene();
}
Although, why are you calling them in Update? We could do with more code for context.
works great. it's better to write them again each time. Thanks