Struggling with events & conditional aborts

simcrewdev

New member
I'm trying to hook-up events coming from a different system to basically control a Behavior Tree.
Sending/receiving events works quite easily, however I'm struggling to switch between branches based on these events & conditional aborts.

For example:
1625835574256.png

Whenever I trigger 'Event 2' first, I can still switch to Patrol by triggering 'Event 1', since the abort is set to Lower Priority. However, once the agent is in Patrol, I can no longer abort this task by sending 'Event 2'.

I'm running into the same issue when I use a Conditional Evaluator with 'Has Received Event' as conditional.

What would be the best way to set up such a behavior? Any help would be greatly appreciated!
 
Your rightmost event isn't going to be received unless it happens to trigger the same frame the first event returns failure. This page has a good example of setting up a tree with events:


You should always have a lower priority branch active.
 
Yes, I have read the page about events. The problem is that I have multiple branches that should have the same priority, where the active branch should be determined by events. Basically a finite state machine, where each higher-level state is determined by an external system (which sends events) and inside each state/branch I'm using regular behavior designer tasks & flow.

Is there any way to get such a set up running with Behavior Designer? Or am I better off looking at FSM packages?
 
There isn't a way to have multiple conditional tasks reevaluate with the same priority, but you could create a new conditional task that for example allows you to receive multiple events. Your new task could save off a variable which specifies which event was received so you know if the agent should go to patrol or idle. You will want to attach an idle task at a higher level though in order to keep the tree active so it will always be able to receive the event with conditional aborts.
 
Thanks for the reply. I have now solved it by creating a shared variable which holds the last received event, with a Conditional Evaluator for each branch which simply checks this shared variable (with 'Reevaluate' on, so it will switch when needed). This shared variable gets set whenever the external system fires an event.

Thanks again! :)
 
Top