Reset animation ?

Hi Guys

i want to know if its is possible to reset the animations after playing it once’s?

thank you

Is Animation.Rewind what you’re after?

HI andeeee

we checked it out but its not what we r looking for

thanks any ways :slight_smile:

Can you give a bit more detail about what you want the animation to do?

HI andeeee

I have a Dice animation that gets played after the user taps the screen of iPhone/iPod, The animation is simple the dice get rolled they pop up to the screen stay there,Wat i want the animation to do is after it plays onces the dice should return to there original place.

thanks

Are you setting the animation playing again? If not, telling the animation to play again (with speed 0 to stop it actually moving) might be necessary in order for the animation to physically update after the rewind.

Hi sybixsus2

im not sure if we have kept the animation to play again but let us check, it might do the trick.

You may need to use SampleAnimation which is a function of the gameObject class. Here is a untested example but you should get the point…

var animClip : AnimationClip;
var gmObject : GameObject;
// initial variables

animClip = transform.animation.clip;
// default animation clip attached to this object

gmObject = transform.gameObject;
// link to the game object class (for SampleAnimation)

gmObject.SampleAnimation(animClip, 0);
// move the playhead to the beginning (0 seconds)
// the second argument is the animation 'time', not a frame

gmObject.SampleAnimation(animClip, animClip.length);
// move the playhead to the end of the animation

gmObject.SampleAnimation(animClip, (animClip.length/30));
// attempt to move playhead to the second frame (end of first) assuming animation is 30FPS

animClip.Play();
// play the animation from where the playhead is

animClip.Rewind();
// rewinds the clip but does not move the playhead

Hope this helps get you started.