Why isn't this coroutine fully firing?

This weird bug is throwing me for a loop.

I’m calling this coroutine:

private IEnumerator LoadDelayed(Vector3 position) {
        Debug.Log("Part 1");
        yield return new WaitForSeconds(1);
        Debug.Log("Part 2");
        this.transform.position = position;
        Debug.Log(this.transform.position + ", " + position);
        Game.PAUSED = false;

But the output is only this forever:

It should also be noted that the none of code after the WaitForSeconds executes, not just the Debug.Log

Edit: I’ve found a different workaround for my purposes, but I’d still be curious to know why it wasn’t working. The coroutine is being called after loading a scene, could that be the issue?

There may be 2 reason for this to happen :

  1. Your Time.timeScale is set to zero . So your code is stopped at WaitForSeconds(1).Try using WaitForSecondsRealTime(1) to see if execution continue?

2.Your Gameobject that has this scripts attached to it is destroyed right after Debug.Log(“1”) is called when new scene is loaded . Make sure that your gameObject is still alive or call


at the Start() or Awake() of your coroutine script to prevent your GameObject to be destroyed after loading new scene .