How to abort the wait task (BT)

How can I set up the tree so that the decorator gets called every frame to abort the task immediately when a certain condition checks out. I have a wait task and a decorator that works properly, but it only gets called after wait time is over. I tried to set the decorator to abort self (suggested here as a way to get it called every frame: Simple Parallel Freezing - AI - Epic Developer Community Forums) , but that doesn’t seem to help.

My decorator is a C++ decorator deriving directly from UBTDecorator.

Anyone got any ideas how to call decorators every frame ?

Hi, to abort a task, you should use the ‘observer aborts’ in descriptors.

check this post :
https://forums.unrealengine.com/archive/index.php/t-130.html

[Epic]Daniel Broder
03-25-2014, 08:16 PM
Conditional Decorators: “Observer Aborts” Property

One critical thing you’ll notice if you select either the “Needs Ammo” or “Has Enemy” nodes in the BotBehavior tree is that they are both set to “Observer Aborts” “Lower Priority”. Our conditional decorators support event-driven changes to make the behavior tree more efficient. Rather than having to iterate over the entire tree constantly as in the most basic behavior trees, we can register for an event if a conditional changes that should cause the tree’s execution flow to change.

If “Observer aborts” is “None”, then only during traditional BT execution will the conditional check of a decorator matter. So for example, if you have a simple check such as “is Blackboard entry Enemy set?” (i.e. not NULL), it will only check as the execution moves through the node into the subtree. If later it becomes NULL in that subtree, execution won’t instantly leave the subtree (though it might exit due to failure of some task that requires that value). Similarly, if execution is in a lower priority subtree, it won’t instantly know that the condition for a higher priority task has been satisfied, so the lower priority task will continue until it succeeds or fails normally. Then, execution through the higher priority branch may discover that that task can be executed.

However, if you set “Observer Aborts” to “Self”, then while execution remains in the subtree, if the status of that decorator changes, it will cause the tree to abort immediately. For example, if the Enemy becomes “Is Not Set” (NULL)), it will abort (basically failing up the tree).

If you set “Observer Aborts” to “Lower Priority”, then while the execution is in a lower priority subtree, if the condition is satisfied such that execution can move into the higher priority subtree, then the lower subtree will abort immediately. So, if the behavior tree is doing the “Idle” behavior and the Enemy becomes set it will immediately abort the lower priority tree (“Idle”) and begin the higher priority tree that was prevented by the “Has Enemy” node being false previously.

“Observer Aborts” “Both” means that it will abort both “Self” AND “Lower Priority” trees.

NOTE: If there are multiple nodes that are all set to abort “Lower Priority” (or “Both”), they will all have to be satisfied before the lower priority tree will be aborted. That way, you won’t have to worry about separate value changes repeatedly aborting your lower priority tasks when the higher priority task can’t actually execute.

To help visualize the “Self” and “Lower Priority” trees in the editor, if you select a specific decorator, it will highlight “Self” and/or “Lower Priority” nodes in the tree (depending on the “Observer Aborts” property). In the details view you can see the key which shows which color is Lower Priority (a light blue at the moment) and which is “Self” (currently a teal-green).