Download

Behavior Tree: force evaluation of BT even is there is task running.

I’m in process of implementing Utility AI for Unreal, after getting somewhat workable prototype, I decided my next step would be either integrate into behavior tree or create my custom editor.

For now I have gone with the first approach. There is much work done on tooling side, and there is no reason not to reuse it.
Unfortunetly current behavior of BT do not really lend it self into my Utility implementation.

When task from Utility selector will be selected it will lock into this task, and wait until this task will be finished (or aborted).
I need the Utility Selectr to constantly (for examply every frame, every 0.1s) evalute possible tasks (or other Utility selctors) for score, and if at the time, different task will be higher scoring, abort the current one start new one.

My question is, how to make selector constantly evaluate it’s children, even if there is child task running ?

The UE4 behaviour trees don’t work that way, but you can hack it to achieve the same result. For example, you could have a decorator on the node which, if it becomes true, can abort the task, allowing the subtree to be re-evaluated. But it wouldn’t really work well for evaluating utility on a bunch of different tasks. Behaviour Trees and Utility Systems are quite different ways of viewing activity choices.

It might make more sense to do most of the utility calculation logic in a regular event-driven Blueprint or in a Service, and the Behaviour Tree would simply be a Selector containing a list of Tasks, each guarded by a Decorator checking whether it is the currently chosen task, and with the Observer Aborts Self option selected to stop the task if it’s no longer the desired one.