I am having some trouble getting a delay to work in the Update functon. I'm trying to call a blinking function on a loop so it waits a few seconds before blinking, then blinks, then repeats.
I tired to us a while loop but it just creates infinite recursion. After that I tried to use a blinkwaiting fucntion to hold the yield waitForSeconds function but I'm still having infinite recursion.
Any help would be wonderful thank you.
The question has been closed Apr 27 '13 at 12:10 PM by Fattie for the following reason:
isBlinking is always false so you're going to be running through a new
I've seen a lot of coroutines run from the Start function so you might want to consider trying that. I.E.:
Check out the docs for more examples (also search the site, there're some around).
answered Jul 21 '11 at 03:21 PM
have you considered to use simple timing/counters with states?
You could keep a floating counter like:
then inside your Update() you manually decrease with the Time.deltaTime value.
answered Jul 21 '11 at 03:29 PM
Not sure you still need that information, but anyway :
answered Jun 12 '12 at 01:38 AM
I've never been a fan of StartCoroutine and yield. I much prefer using Invoke and InvokeRepeating.
You can have a blink count variable and a conditional to check how many times it has blinked, and have a TurnOff() function that will Invoke the TurnOn() function in 0.3 seconds or 3 seconds depending on whether it's done blinking, and CancelInvoke() when it's done.
answered Aug 02 '12 at 10:15 PM