Hey @Justin
Can you see why this script wouldn't be receiving an animation event? I'm trying to set up a wait for animation node - it's based off the wait for animation state node.
Thanks in advance,
Nathan
Can you see why this script wouldn't be receiving an animation event? I'm trying to set up a wait for animation node - it's based off the wait for animation state node.
Thanks in advance,
Nathan
Code:
namespace BehaviorDesigner.Runtime.Tasks.Unity.UnityAnimator
{
[TaskCategory("Unity/Animator")]
[TaskDescription("Waits for an Event from the Animator")]
public class WaitForAnimationEvent : Action
{
[Tooltip("The GameObject that the task operates on. If null the task GameObject is used.")]
public SharedGameObject targetGameObject;
private bool canContinue = false;
public override void OnStart()
{
EventHandler.RegisterEvent(targetGameObject, "OnContinueAnimatorComplete", SendAnimEvent);
}
private void SendAnimEvent()
{
canContinue = true;
Debug.Log("Event Recieved");
}
public override TaskStatus OnUpdate()
{
Debug.Log("Waiting For Event");
if (canContinue) {
Debug.Log("Event Executed");
return TaskStatus.Success;
}
return TaskStatus.Running;
}
public override void OnReset()
{
targetGameObject = null;
canContinue = false;
EventHandler.UnregisterEvent(targetGameObject, "OnContinueAnimatorComplete", SendAnimEvent);
}
}
}