x


Fast-forwarding animations

Hi all.

Is there any way of fast-forwarding to the end of an animation? I have objects that assign animations to the camera for shaking and the sort, and all of them start and end at the same state (zero rotation and no effects on the camera).

If one object adds an animation when another animation is playing (it's added to the same animation component, obviously) the other just vanishes, and the camera isn't completely reset. I need a way to fast-forward (or rewind, for that matter) the previous animation so that in the end, the camera is in neutral position and rotation.

I tried animation.Rewind() and animation.Stop() but for some reason (most likely that the new animation clip is added in the same function before the animation component has time to reset the camera) it doesn't work. Waiting a frame also fails, leaving the animation at frame 1 rather than zero.

How do I do this? Any help is greatly appreciated!

more ▼

asked Jul 05 '11 at 01:23 PM

Arshia001 gravatar image

Arshia001
91 11 12 14

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

1 answer: sort voted first

you could do something like that:

AnimationState s = aniamtion["Your animation"];
s.time = 0; // desired time/frame
s.enabled = true;
s.weight = 1;
animation.Sample();
s.enabled = false;

That should put transforms in the positions of time 0.

more ▼

answered Jul 11 '11 at 01:13 PM

Paulius Liekis gravatar image

Paulius Liekis
7.3k 16 24 46

(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:

x3806
x5

asked: Jul 05 '11 at 01:23 PM

Seen: 615 times

Last Updated: Jul 11 '11 at 01:13 PM