Coroutoutine doesnt work properly.

I have this coroutine

   IEnumerator Test(GameObject p)

        yield return new WaitForSeconds(0.4f);


which is running properly till print(“s”); but doesnt after yield return new WairForSeconds(0.4f);

Any ideas?

You either have:

  • destroyed the gameobject / script where the coroutine runs on
  • set your Time.timeScale to 0 in which case the WaitForSeconds will wait forever.
  • or you call StopCoroutine / StopAllCoroutines somewhere on that script.

Make sure p is not Null.
You can do a null check like this


The Coroutoutine crashes do not return a error message, unless you use try{}catch(){} and log it your self.
I think it is because its not rum in the MonoBehaviour class, but i might be wrong.

yeah, how does the coroutine start? Try this

public float PrintSomething = .8f;//variable for coroutine delay

void Awake()

	private IEnumerator letsPrint(){
		yield return new WaitForSeconds(PrintSomething );
print ("s");