Unity Animator gets the currently playing animation clip

Animator obtains the currently playing segment, gets an error, and the reason why it is inconsistent with the currently playing segment.

Generally use the following API to get the current animation machine playback clip:

//当前为Idle,现在切换到Run  
AnimatorStateInfo  animatorInfo = animator.GetCurrentAnimatorStateInfo(0);
currAnim.IsName("Run");//这里获取到的还是Idle

There is a mechanism here. If the previous code is to play an animation segment, the next code immediately obtains the information of the current playback segment, but it cannot be obtained. It needs to wait for a delay of tens of milliseconds to correctly obtain the information of the current playback segment. This is because animation clip transitions have a transition time.

Guess you like

Origin blog.csdn.net/Ling_SevoL_Y/article/details/129164528