something that may help when you want to stop an animation but do not know which one is actually playing.
using UnityEngine;
using HutongGames.PlayMaker;
[ActionCategory(ActionCategory.Animation)]
[Tooltip("Get the current animation name and store it in a string variable")]
public class GetCurrentAnimation : FsmStateAction
{
[RequiredField]
[CheckForComponent(typeof(Animation))]
[Tooltip("A Game Object with an Animation Component.")]
public FsmOwnerDefault gameObject;
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmString storedString;
public override void Reset()
{
gameObject = null;
storedString = null;
}
public override void OnEnter()
{
DoGetCurrentAnimation();
Finish();
}
void DoGetCurrentAnimation()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if(go == null)
return;
if(go.animation.isPlaying)
storedString.Value = go.animation.clip.name;
}
}