How would I get the animation length with Mecanim? With legacy it used to be along the lines of animation[“myAnimation”].length. But now that doesn’t appear to work.
Does anyone know a way to get the length of an animation with the new system?
Thanks.
3 Answers
3
As far as i am aware, this is not possible atm, and i am not sure when we will get such stuff. The only thing i could find is using GetCurrentAnimatorStateInfo and its .length property, but i am not sure if it is 100% accurate.
float value = anim.GetCurrentAnimatorStateInfo(0).length;
I could solve it via AnimationEvents
So you can react to a specific frame
Bumping because Unity devs should have fixed this issue long ago. Any real game dev will run into this problem when using Mecanim so it NEEDS to be addressed ASAP.
– oscarkoolI tried this out yesterday and it seems to work. You can also verify the name of the animation and the value it provides compared to what it shown when you preview the animation.
– sarcasteak