Another way to get animation length?

I’m just curious to see if there is another way to get the length of an animation I want to play. I’m using mechanim and going from an idle state animation to an attack animation. I don’t want the player to be able to do any inputs or new animation triggers or anything.

Right now I have a simple answer, I store the Animation Clip and the animation trigger in a scriptable object (with other info of course) So when I want to perform the attack I just call the animation and a set a timer that is based on the animation clip length. Simple and effective.

I’m just wondering if there is a more efficient way to do this without having to store the animation (I have a ton of animation files so finding a specific one is tricky at best) is there a way I can do something like “currentAnimation.length” or anything else?

It just seems wasteful and difficult to store the clip but not be able to play the clip (have to use mechanim triggers)

My thoughts exactly, which is why I made Animancer (link in my signature). It lets you avoid the need for Animator Controllers and just give your scripts direct references to the AnimationClips they want to play. To play an animation you can just call animancer.Play(clip) without needing to set anything else up beforehand.

Sounds handy! I’ll have to look into that one and see if it works better for me