foriero đã viếtThanks Spiral, I will look into Mitch's implementation. In the meantime I did create new action and cleaned a bit the old ones. The new one is called SpineEventConditionAction.cs. Just set your condition on what you want to react and you are good to go.
Please download actions from initial post of this thread.
have a question for you, how to implement a script for Animation Event. For example, in Spine2d on the desired animation, I created an event for example "Wrong" and I want to be sent to SendEvent on detection. I nowhere to find examples related to Spine in Animator. I found one method, but it's a little different, jy defines the end of the animation but it does not work correctly, below I can apply this script can be useful.
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Artix")]
[Tooltip("Artix Production")]
public class SendEventEndAnimation : FsmStateAction
{
[RequiredField]
[CheckForComponent(typeof(UnityEngine.Animator))]
[Tooltip("The GameObject to be observed.")]
public FsmOwnerDefault gameObject;
[RequiredField]
[Tooltip("Send this event when animation finished.")]
public FsmEvent sendEvent;
[RequiredField]
[Tooltip("The name of the animation to be observed.")]
public FsmString animationName;
private Animator animator;
public override void Reset() {
gameObject = null;
sendEvent = null;
animationName = null;
}
// Code that runs on entering the state.
public override void OnEnter() {
var go = Fsm.GetOwnerDefaultTarget(gameObject);
animator = go.GetComponent<Animator>();
}
// Code that runs every frame.
public override void OnUpdate() {
var a = animator.GetCurrentAnimatorStateInfo(0);
if (a.IsName(animationName.Value) && a.normalizedTime >= 0.98f) {
Fsm.Event(sendEvent);
}
}
}
}