I'm running this coroutine:
Under Update() in an attempt to always give the player an incorrect display of several stats.
But, as it stands, running that changes the value so quickly that it hurts one's eyes. WaitForSeconds isn't doing anything to slow it down.
What am I doing wrong?
asked May 20 '12 at 06:47 PM
The question has been closed Dec 15 '12 at 08:56 AM by burnpsy for the following reason:
The question is answered, right answer was accepted
The waitForSeconds is actually useless at this point. There is nothing after the yield statement. Coroutines run kind of parallel to your other code (not really parallel but almost ;) ).
When you start a coroutine a new coroutine object is created which is handled by Unity's coroutine scheduler in the background. You can't halt or delay Update. Update will be called every frame. Whenever you use StartCoroutine you create a new independent instance of thie coroutine.
You propably want something like that:
This will start one coroutine which will run forever and that changes your variables once a second.
answered May 20 '12 at 07:18 PM