# How to stop an animation on last frame until condition is met in Unity?

I have an animation (fishing) I want to play backwards when the player catches something or cancels the action.

Playing the animation backwards is as simple as setting the speed to -1, ie:

anim.SetFloat("direction", -1.0f);


However, my fishing animation keeps playing until I have caught something, or cancel the animation. This means that the last frame of the animation is showing, but the time of the animation is still going.

So

• the animation reaches the last frame
• then I stand there for 8 seconds,
• I catch something, so I change anim speed to -1
• anim will now reverse those 8 seconds I was "standing still" first, before it even reaches the actual animation.

I need to stop the animation time on the last frame (without leaving the animation), so that reverse will be instant. And to not exit the animation until the reverse is finished. Maybe there is some other way to do it, but I can't figure it out.

I could create a seperate animation for when I want it to go backwards, but that seems sloppy.

//create parameters in the animator and update from a player state or some sort of controller script.