animation stop & go to frame 0

Hello everyone, my question is simple but I couldn’t figure out what should I do. When player is not aiming my gun has idle breath animation. I want to stop it when player starts aiming. But using Stop() just pauses the animation, not like stoping at all. I mean for example breath animation is in 30. frame, and player aims. Then it stops at 30. frame and as a result weapons position is being different. I want to make it actually stop, which means animation is going to go to the 0. frame and stop.

function Update(){
if(!aimed){
animation.CrossFade("idle");
}
if(aimed)
{
// some code that make it stop and go to the 0. frame again. (not .Stop(); code)
}

thanks :slight_smile:
}

If you have an animation named “breathe” then you can go to a particular time in the animation with:

animation["breathe"].normalizedTime

or

animation["breathe"].time

If you want the current animation to play to the “end” and then stop, use:

animation["breathe"].wrapMode = WrapMode.Once

To determine when the current animation has ended, you can test:

animation.isPlaying