ConditionalAbort logic

bbjones

Member
I seem to keep running into this design issue in my BTs.

I have an abort that triggers when a value changes - this works as expected.

But, in the branch under the abort, when the value or condition that triggered the abort becomes false, the abort branch exits.

I guess I'm expecting that once an abort branch starts that it will finish the branch before execution returns to lower priority branches.

One way I see around this is to set a flag that is turned on when the abort condition happens, then turned off by the abort branch itself at the point where I want the branch be considered complete.
I've seen you post about using parallel branches for similar scenarios but I don't want multiple branches running, I only want my abort branch to always finish once it's started.

Or maybe I shouldn't be using conditional aborts for this scenario? If that's the case what would replace it?
 
Last edited:
The major thing to keep in mind with conditional aborts are that they will trigger when the task status changes, from failure to success or success to failure. If you don't want the abort to occur when the active branch is running then make sure you are just using a lower priority abort. For anything else you will need to use the interrupt/perform interruption tasks since you are looking for more control over when the abort happens.
 
Ok I think I'm clear on how aborts work, but I don't really see how interrupts would help.

The scenario:
  • agent is collecting resources
  • at some point the agent becomes full and needs to go unload
  • at that point I want to stop the "collecting" branch and start the "unloading" branch
  • continue unloading cycles until unloading is finished
  • resume "collecting" branch
I need some sort of custom task checking for when the agent is full, but I don't see how that can connect to a PerformInterrupt task.

One way I can see it working is at the end of every "collect" cycle I have a new custom task that checks if the agent is full, if so they set a flag that is used by an higher priority abort. Setting the flag to true engages the abort.

The abort has a custom task run at the end of each cycle checking if the process is complete. Once it is, the flag is set to false which exits the abort branch and can then resume the lower priority collect branch.

Is there a cleaner way to do it without setting/unsetting flags for the abort?
 
I would need to see your tree in action in order to confirm but having a separate flag is likely the way to go. I even do this within the Ultimate Character Controller integration tree. The conditional aborts will reevaluate based off of that flag that is set elsewhere within the tree:

 
Top