Animation state get current frame

Hi,

I am curious about how to get via script the current state of an Animation State. Does something like

this.animation["xxx"].frame

exist?

If not, how can I get an int representing the current frame of an AnimationState?

Thank you.

From what I’ve seen you can either do AnimationState.normalizedTime which returns the progress of an animation on a scale of 0 to 1. So if you have a 30 frame animation and you want frame 15, you can do if (normalizedTime == 0.5)* Or the better and more reliable option is to use AnimationEvents that fire on specific frames.

*You won’t really be able to do this if we’re dealing in floats–You can only get the approximate value or you’ll have to check greater then or equal to 0.4 AND less then or equal to 0.6 because the animation could go faster than the current frame rate or the normalized time value could be 0.50000001 because of the nature of float values.

@SomeGuy22 Than NOT Then