hey all! anyone know why ‘animation.Rewind();’ doesn’t rewind an animation? I want to reset it to it’s start point. Is this a bug or am I not using the command correctly?
It plays forward just fine.
tx!
–Roy
hey all! anyone know why ‘animation.Rewind();’ doesn’t rewind an animation? I want to reset it to it’s start point. Is this a bug or am I not using the command correctly?
It plays forward just fine.
tx!
–Roy
It’s possible that you may not being using it correctly. Post a few lines from your script and we can take a look.
thanks -
I run the animation using this:
animation.Play("Default", PlayMode.StopAll);
and I am trying to rewind (i.e. go back to the first frame of the animation using this:
animation.Rewind();
It’s not throwing any errors - it’s just not returning the object (that the animation is attached to) back to it’s starting position.
–Roy
Hmmm… is the frame that it remains on (when it should be rewound) telling at all?
I.e. do you have anything that is locking it that frame (ClampForever maybe?)
Rewind does not start an animation automatically. Since you stopped it before, it will still be stopped after Rewind as well, thus after the animation is stopped it wont modify any values on the transforms or whatever you are animating.
I’m not sure I understand. I wasn’t expecting Rewind() to start my animation, I expected it to return the animation to it’s first frame (like rewind does on a VCR: return to the beginning). If this isn’t what Rewind() does, that’s cool (though I don’t know then what it does). I just want to get my animated object back to it’s starting point. Should I just store the transform and reapply it? (mm… how do I do that ;-))
Seems like you just want to sample a specific clip at a given time:
http://unity3d.com/Documentation/ScriptReference/GameObject.SampleAnimation.html
gosh, I only want to do something really simple. Maybe my description is making it sound more complicated
I have an animation that moves X from A to B which I created through the Unity animation UI.
X: A -------------------> X: B
At a later time I want X to move back to where it was before the animation (i.e. the starting point A of the animation). I am making the assumption that X is still “under the influence” of the animation - so calling ‘Rewind’ made sense with that assumption. Maybe that is my error?
English is my first language so I tend to abuse it! ![]()
Great timing on this thread… I just ran into this problem earlier today trying to set an animation to a specific frame while also being able to stop it in the same Update and SampleAnimation solved it.
tomjoad, if you’re trying to set the animation back to the start without having to play it again to get to that frame SampleAnimation is your friend.
Grapes of Wrath is my favorite book ![]()
Yeah - mine too
Do we have a solution on this one?
Cause it’s still broken.
Developers, developers, developers?
Guys, seriously, I need to rewind my animations! Tried to do that in different ways - the Rewind() doesn’t work at all. Period.
The other way is I just made is this - I wait for animation to finish and then make it go back “realy freaking fast :)”
animation["Default LW Animation"].speed = 2.0f;
animation.Play("Default LW Animation");
while(animation.IsPlaying("Default LW Animation"))
{
yield return new WaitForSeconds(0.1f);
}
animation["Default LW Animation"].speed = -50.0f;
animation.Play("Default LW Animation");
This one works only for the first time - when I call this again the animation doesn’t work at all, it just stays in a static position and doesn’t move.
Here is the next try - I play an animation and then just destroy the GameObject and instantly instantiating the very same prefab again. BUT IT DOESN’T WORK EITHER!!! :(((((( When the new GameObject appears on the screen the animation is in its very final position as it has been already played!
“Please, I need help!” (c) “Serious Man”
P.S. The rabbi doesn’t look busy =\
gameObject.SampleAnimation(animation.clip, 0); - this one solved the problem, thank you! oh, wait…
If you have a reproducible case where animation.Rewind doesn’t work then please can you file a bug report about it. The last activity on this thread was nearly three years ago - it’s possible that the problem was not followed up for some reason.
yes, for this reason:
gameObject.SampleAnimation(animation.clip, 0);
it’s always the same (and with me it’s also gonna be the same) - the Rewind is broken, but it’s ok, I’ve found a workaround ![]()
The SamplAnimation worked, but only puts gameObject position in the frame 0 of the clip from the animation and the animation does not run backwards (animation.Rewind), so soft (frame by frame) as I need.
How I could do?
animation.Rewind() only works when an animation is playing
animation is basically the animation component attached to the gameObject you are animating, if this gameObject is not playing any
animations, you cannot use animation.Rewind() cos there will be nothing to rewind
If you want to play an animation backwards, you use negative speeds. so put the speed at -1.
I hope I am saying this correctly, been a while since I have used it.
i find the way,Fast forward to the end of the animation first。
animation[“New Animation”].normalizedTime = 1f;
animation[“New Animation”].speed = -1;
animation.Play();
thanks wakerunity.