in unity how to get the animation that currently play code example
Example 1: 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 2: how to play animation with code in unity
public GameObject ExampleNPC;
void Update()
{
if(Input.GetButtonDown("Animation"))
{
ExampleNPC.GetComponent<Animator>().Play("Anim name");
}
}