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!

you could do something like that:

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

That should put transforms in the positions of time 0.