Want I want this to do is send ‘dead’ and such, wait 2 seconds, and then reload the level with Application.LoadLevel. I call the coroutine later like this:
StartCoroutine(MyMethod());
The Debug.Log(“Dead”); is sent and everything before, but nothing after the 2 seconds happens, including the second Debug.Log! Anyone know what part I’m phrasing incorrectly? - JS
I would be surprised if this is the case, Since there is no yield statement after the call to LoadLevel and I don’t think unity would hijack execution from you without any yield specified.
I would more bet that the script or or the gameObject the script is on is PlayerSprite which you destroy prior to the wait.
probably important to note that unity won’t ‘stop’ the coroutine immediately with the call to delete ( as it’ll never just eject your code ), rather if you yield return after the object was destroyed within the coroutine, control will not be returned to the coroutine.
The answer, as it turns out, was that part of the coroutine involved destroying the player, the gameobject the script itself was attached to. Once it was destroyed, the coroutine couldn’t continue… thanks for all of your help!