- Home /
How do you rewind an animation that isn't playing?
I'm using an animation to hide an object, so when I reset the scene, I want the animation to be at the start of the 'Show' animation. I can't seem to make this happen unless the animation is already playing at the time.
I've tried animation.Stop(), animation.Rewind(), and animation["ClipName"].time = 0, but they don't seem to do anything unless the animation is already playing. I've resorted to creating "Reset" animations which just have two keyframes of the hidden position - but this is less than desirable. Surely there is a more direct way?
I'm amazed that animation["ClipName"].time = 0 isn't working for you - are you sure that the animations aren't playing behind the scenes?
I'm sure, I can see the object in the editor. I'm guessing that object is only updated if it's actually playing. So time=0 rewinds the clip for the next time it's played, but not the object itself.
Answer by IT_Criminal · Nov 25, 2012 at 09:33 AM
animation["ClipName"].speed = -1;
will make an animation play backwards
animation.Play("ClipName");
animation["ClipName"].speed = -1;
animation["ClipName"].time = 0;
will make the animation snap to the first frame
animation.Play("ClipName");
animation["ClipName"].speed = 1;
animation["ClipName"].time = animation[ClipName].length;
will make the animation snap to the last frame
hope it helps ....
Yeah... I know. But I want to instantly go to the beginning of the clip (since the camera is looking at the object in this case), so reversing the animation is not an option. I could speed the animation up to be super fast... but again, this seems like a hack, I figured there would be an easier way.
oh ... why not say like that ... look an the new answer
Your answer
Follow this Question
Related Questions
Animation.Rewind Isn't Working 1 Answer
ANimation doesn't rewind on animation.Stop 3 Answers
pingpong animation question 2 Answers
Can the animation editor create local rotational data? 3 Answers
Adding animation clips via script 2 Answers