Is there a way to shorten an animation in code?

I have an animation clip that moves very slightly too far at the end of the animation. Is there a way I could “cut off” the end of the animation in code?

I’ve looked in the manual on the Animation and AnimationState sections but have not seen anything.

Anyone know if there is a way I could do this? I’m using a purchased model so I don’t have access to the original rigs to edit it myself.

Hi there the easiest way to do it would be to change frame number on the imported animation…

click on the imported object in unity.

and then in inspector change the start and end frames .

hope that helps

//Stops the animation after 5 seconds of playtime.
if(5 < animation["myClip"].time) animation.Stop();

Hope that helps