How to go to starting point of an animation which is running already?

Hi.
I am kind of a beginner to Unity.

So. an animation(which is a prefab.) is playing in my run time. I want to include a script to this prefab which makes my animation play from starting point on some condition.

Help me in solving this. Or correct me if I had misunderstood things wrongly.

Thanks in advance. :slight_smile:

The animator component has a Play() method that accepts an animation state and also a point in time of the animation in which you want to start from:

You can use this code from a script attached to the same object as the animator:

string startAnimationState = "StartState";
Animator animator = gameObject.GetComponent<Animator>();
animator.Play(startAnimationState, -1, 0);

Assuming the state you want to restart playing is called “StartState” in the animation controller, and that you only have one layer.