Controling behavior tree scheduling

I was wondering what is the best way to control behavior tree scheduling. Behavior trees are being run very frequently (every frame?), and there may be cases where this is not desirable. For example when having lots of AI entities on the map. The way I found to slow down evaluation of the tree is to put a sequence below the root node with a Wait node followed by the rest of the tree. If I set the Wait node to 0.1s, my tree will be evaluated 10 times per seconds which is fine. Questions:

1.Is using a Wait node the right way to do it?

2.Can I, from C++, dynamically change the Wait time of a Wait node. If AIs are far away from the player, I would like to slow down their behavior tree polling.


I’m nowhere to be even decent in Unreal’s AI system (or in any AI system for that matter), but as far as I’m concerned, BehaviorTrees are pretty well optimized “out of the box”.

I think they are not ticking in the “traditional” way, the are listening to Decorators and active Services(which are indeed ticking, and the interval can be set), and only evaluate themself when needed.

I know that you can also save on performance if you are not instantiating your BTTasks, but use NodeMemory instead.

Someone who actually knows this topic might give you a proper answer…

Have you seen this?

If looking at a behavior tree while the game is running you will see it ticks like crazy. I don’t know how it works under the hood, but I am not sure the implementation is that much CPU efficient. Would be good to have some details from Epic on the way behavior trees are evaluated.

Do you have a task that can be executed by the tree? If it flashes really fast, it usually means that it was not able to find a valid task to execute.
It would be helpful if you could show your tree, as the problem might be in your setup.

If you really want to, you can inherit from BTTask_Wait, or just by looking at the implementation of it you could write your own WaitTask with the desired behavior.

Under the hood behaviour trees are event based, that’s what the official documentation states.

Yes, however, I believe OP is experiencing this and thought this is the intended behavior: