StopBehaviorTree task with pauseBehavior enabled creates a stuck state

lukeiy

New member
As per the title, when resuming the tree it re-runs the StopBehaviorTree task, so your tree gets stuck in a state of constantly paused. I would have expected the node completes and THEN the pause starts, so it resumes at the next node on the tree.
 
What do your behavior trees look like? I just tried something similar and it worked:

1669880150008.png
 
1669900478447.png

This is the part where it gets stuck, I added a log to the SetTrigger task which you can see. When the animation ends it fires an animation event which is recieved by a script, which enables the tree again.

// triggered by keypoint in attack animation
private void SkillFinished()
{
Debug.Log("enabling tree");
_behaviorTree.EnableBehavior();
}

you can see the logs show "disabling" immediately after and the tree remains on Stop Behavior Tree.

I'm on BehaviorDesigner 1.7.4, here is my full tree (I disabled the right hand branches at the bottom right)
1669907146155.png
 
Last edited:
I get similar behavior Pausing and unpausing the script through code:
1669906016832.png

If I pause the behavior inside the event, then resume it later once the animation finishes (with the same animation event), the tree resumes inside the Send Event, where it calls the Update function a second time, and it gets stuck in a loop.

// function called by Send Event
private void StartSkillAnimation(object skillIndex)
{
Debug.Log("starting skill");
_behaviorTree.DisableBehavior(true);
_animator.SetTrigger($"Attack_{skillIndex}");
}

// function that resumes the behavior
private void SkillFinished()
{
Debug.Log("Skill finished");
_behaviorTree.EnableBehavior();
}
 
After I re-enabled the branches on the tree, it started working without any other changes. Is there some funniness going on with editing the tree within a prefab and clicking play before exiting? I notice sporadic issues sometimes and I'm not sure what the cause is.
 
I am not aware of any. I will play with that scenario though to see if I see anything. Maybe it's an execution order issue between the trees that are running?
 
Top