x


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?

more ▼

asked Apr 10 '11 at 04:43 PM

Algernon 1 gravatar image

Algernon 1
11 1 1 2

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.
more ▼

answered Apr 10 '11 at 04:45 PM

Statement gravatar image

Statement ♦♦
20.1k 35 70 175

(comments are locked)
10|3000 characters needed characters left

you can't use yield WaitForSeconds as an event to freeze your animation WaitForSeconds suspends the execution of your code only .

more ▼

answered Apr 10 '11 at 05:54 PM

Mai hime gravatar image

Mai hime
26 5 9 14

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)

Apr 10 '11 at 06:07 PM Statement ♦♦

how do i set animation speed? and it can be changed for each frame?

Apr 15 '11 at 07:16 AM Algernon 1

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

Apr 15 '11 at 07:35 PM Mai hime
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3768
x333
x58

asked: Apr 10 '11 at 04:43 PM

Seen: 1297 times

Last Updated: Apr 10 '11 at 04:43 PM