How to check if the animation is running or not ???
What is the proper code for this?
How to check if the animation is running or not ???
What is the proper code for this?
I suggest you see this post.
You could have found it with a quick search…
assuming you are using unitys animator component:
https://docs.unity3d.com/ScriptReference/Animator.html
//get the aminator component
Animator anim = gameObject.getComponent<Animator>();
//get the state info, this includes current animation, progress, time etc.
AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0); // number is the layer, 0 means the first layer from the top
//animations are identified as hash, not as string name
int currentAnimHash = stateInfo.shortNameHash;
//get the hash of the animation you want to check
int myAnimHash = Animator.StringToHash("myAnimName");
//check if this animation is currently playing
if(currentAnimHash == myAnimHash ) some code
code is not tested