Adding to the BehaviorTreeReference during runtime?

monochrono

New member
Hey, i'm having some trouble adding external behaviour trees at runtime to a subclass of the BehaviorTreeReference class. When I try to fetch it via script via:

behaviourTree.FindTask<BehaviorTreeReference>();
behaviourTree.FindTaskWithName("Job list");

I get null in both cases. It works fine if I try to get any other task in the behavior tree. I have also tried to subclass BehaviorTreeReference as was mentioned in some other posts but I simply can't get it to work. Do you have an example on how I can dynamically add external behaviour trees at runtime to a BehaviorTreeReference task at runtime?
 
The BehaviorTreeReference task is consumed when the tree starts so it no longer exists. You will need to make sure you call FindTask before the behavior tree is enabled.

An easier method is to subclass the BehaviorTreeReference task. You can then override GetExternalBehavior and provide your own array.
 
Ah okay, so I can't actually dynamically add tasks to the behaviour tree while it's running. Only right before the behaviour tree starts?
 
That's correct. If you want to change it at runtime you can use an external behavior tree and reassign the ExternalBehavior property so the BehaviorTreeReference task is available again.
 
Alright, my idea was to have a point in my behaviour tree where I could give agent different jobs dependent on priority and the likes. But it seems then that I would have to end that behaviour tree and add new behaviour trees to be run one by one by some sort of job manager system.
 
Top