Behavior Manager
When a behavior tree runs it creates a new GameObject with a Behavior Manager component if it isn’t already created. This component manages the execution of all of the behavior trees in your scene.
You can control how often the behavior trees tick by changing the update interval property. “Every Frame” will tick the behavior trees every frame within the Update loop. “Specify Seconds” allows you to tick the behavior trees a given number of seconds. The final option is “Manual” which will give you the control of when to tick the behavior trees. You can tick the behavior trees by calling tick:
BehaviorManager.instance.Tick();
In addition, if you want each behavior tree to have its own tick rate you can tick each behavior tree manually with:
BehaviorManager.instance.Tick(BehaviorTree)
Task Execution Type allows you to specify if the behavior tree should continue executing tasks until it hits an already executed task during that tick or if it should continue to execute the tasks until a maximum number of tasks have been executed during that tick. As an example, consider the following behavior tree:
The Repeater task is set to repeat 5 times. If the Task Execute Type is set to No Duplicates, the Play Sound task will only execute once during a single tick. If the Task Execution Type is set to Count, a maximum task execution count can be specified. If a value of 5 is specified then the Play Sound task will execute all 5 times in a single tick.
If you want to persist your behavior trees across scenes you can mark the BehaviorManager as DontDestroyOnLoad. Make sure you also mark your Behavior Tree component that you want to persist as DontDestroyOnLoad as well.