- Home /
help with yield function
Hey I want to use the 'wait' function so that I can freeze my animation for some interval of time. I want to use this 'wait' function as an Event in my animation but it doesnt work.
function wait () { yield WaitForSeconds(5.0); //WaitForSeconds (5); }
why not?
Answer by Statement · Apr 10, 2011 at 04:45 PM
You probably call it like this:
wait(); // Starts a new coroutine, and continues immediately.
But you need to yield to whatever it yields, like this:
yield wait(); // Starts a new coroutine, and continues when coroutine is done.
Answer by Mai hime · Apr 10, 2011 at 05:54 PM
you can't use yield WaitForSeconds as an event to freeze your animation WaitForSeconds suspends the execution of your code only .
Yeah, you'd have to set the speed for the animation state to 0, wait, then set the speed back to whatever it was before (usually 1)
how do i set animation speed? and it can be changed for each frame?
if you want to freeze your animation try this method: 1-split your animation in two (one before where you want to freeze and one after ) 2-call your animations and use wait between them gameObject.animation.Play("first animation"); yield WaitForSeconds (5); gameObject.animation.Play("second animation"); This worked good for me Ps:the animation that i used were imported from maya
Your answer
Follow this Question
Related Questions
Yield until animation is over? 1 Answer
WaitForSeconds Question 2 Answers
C# Coroutine help 1 Answer
Best way to wait for event inside Coroutine? 3 Answers
Yield to wait for delegate call 1 Answer