Hi there,
with the old legacy system I know that you can use: Animation.IsPlaying(“animName”) to return a bool value as to whether or not the specified animation is playing.
Does this same thing exist for mecanim within an Animator?
Specifically I want to do the equivalent of:
if(Blendtree named “Running” is playing)
{
//Do action
}
Can anyone help with this?
It’s a little different then it was before (stuff like blend states can really complicate “what is now playing”). You’ll want to use this function to get the aimator state info. From there you can call the isName() function or check against the “nameHash” from the animatorStateInfo object returned to you and evaluate your logic against that.
Animator some = gameObject.GetComponentInChildren ();
AnimationInfo ainfo = some.GetCurrentAnimationClipState(0);
if(ainfo.Length == 0){
/*** no animation running***/
}else{
for(int idx=0;idx<ainfo.Length;idx++){
}
}