unity check if animation is playing code example
Example 1: unity animator check if animation is playing
bool isPlaying(Animator anim, string stateName)
{
if (anim.GetCurrentAnimatorStateInfo(animLayer).IsName(stateName) &&
anim.GetCurrentAnimatorStateInfo(animLayer).normalizedTime < 1.0f)
return true;
else
return false;
}
Example 2: how to know if the animator playing animation unity
bool AnimatorIsPlaying(){ return animator.GetCurrentAnimatorStateInfo(0).length > animator.GetCurrentAnimatorStateInfo(0).normalizedTime; }
Example 3: unity get currently playing animation
anim.GetCurrentAnimatorClipInfo(0)[0].clip.name
m_Animator = gameObject.GetComponent<Animator>();
m_CurrentClipInfo = this.m_Animator.GetCurrentAnimatorClipInfo(0);
m_CurrentClipLength = m_CurrentClipInfo[0].clip.length;
m_ClipName = m_CurrentClipInfo[0].clip.name;
Example 4: unity detect if animation is playing
if(this.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).normalizedTime >= 1)
{
{