- Home /
Getting Unity Animation to Stop On Frame Zero
Hello. I need to get a spinning ball (using a Unity Animation) with a logo to stop spinning and stay at frame 0. According to the docs:
"Stopping an animation also Rewinds it to the Start." I tried anim.Stop(); and it DID stop, however it did not rewind to start. I've also tried these:
anim.Rewind();
anim.Stop();
anim.Stop();
anim.Rewind();
But neither one works. The ball does stop spinning but it stays on whatever frame it was last on. Is there another way to do this? Thanks! -Mo
Answer by getluky · Aug 05, 2011 at 10:03 PM
Stop rewinds the playhead to the beginning, but it probably does not sample frame zero. Try out the sample code for Animation.Sample:
http://unity3d.com/support/documentation/ScriptReference/Animation.Sample.html
What is Animation.Sample supposed to do? The documentation does not explain and it does not seem to be useful for rewinding to frame 0.
I think I see what it is supposed to do. Sample is used to set the object's parameters to those from a specific animation frame (or rather, time). At first I thought it was some sort of push/pop stack.
'Sample' animates the object to its current time and does nothing else (it puts the pieces where they should be for that time).
Your answer
![](https://koobas.hobune.stream/wayback/20220612171334im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Animation.Rewind Isn't Working 1 Answer
pingpong animation question 2 Answers
ANimation doesn't rewind on animation.Stop 3 Answers
Can the animation editor create local rotational data? 3 Answers
How do you rewind an animation that isn't playing? 2 Answers