- Home /
How to check progress of current animation state in Animator from script?
Basically i want the exact value of the little blue loading bar under an animation state, be it time or normalized time(0-1) Details: So far I have only found a few ways to do it Calculate it from animClip time and transition time as soon as i change state in my state machine and hope they match up.(didn't test this) ...or something like this which i think i'm gonna use
[Range(0, 1)] public float testAnimProgress = 0;
if( myAnimator.GetCurrentAnimatorStateInfo(0).IsName(animName1) ) testAnimProgress = myAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime; if( myAnimator.GetNextAnimatorStateInfo(0).IsName(animName1) ) testAnimProgress = myAnimator.GetNextAnimatorStateInfo(0).normalizedTime;
since i don't know if Animator has entered the state that my state machine is in because of transition time i check for both and only one can be true at a time. Problem is i'm not sure if this is equivalent to the progress in the Animation editor tab, seem pretty close from what i can tell but since i can't find a place where it numerically displays the blue bars progress i can't be certain. I want this so i can enable and disable hitboxes for my attack animations in a certain time frame like 0.2-0.5 among other things. One more thing would prefer not to use coroutines and events in the animation clips(though i'm not sure how these would help). Hope i explained myself enough.