Modular Trees?

kdgalla

New member
Hello, I've played around with Behavior Designer on and off for a few days and easily managed to come up with that really common basic AI pattern: patrol until it see's the player, then pursue the player, attack when close enough, but give up if the player is out-of-sight for too long.

I was wondering though, if were possible to create trees as modular parts. That is, what if I wanted to have several different enemies with the same behavior as above, but say one enemy has one set of nodes to attack (a tree in- and-of-itself ), but another enemy has a different set of nodes to attack. Maybe there is more than one patrol behavior too.

I imagine, on an enemy, selecting one external tree for my overarching behavior, and that tree would have a "slot" for an attack and also for a patrol. I would then drag my chosen attack external behavior tree into the attack slot, and likewise with the patrol slot.

Is it possible to combine behavior trees piece-wise like this?
 
Thanks, Justin. I don't know how I missed that part of documentation. One thing though- Using a reference tree node in my tree, is it possible to assign which external tree to assign in the Unity inspector? Similar to how shared variables are exposed and you can assign their values per instance.

Otherwise, I would need to create something like a skeleton behavior tree for each combination of referenced trees that I want to use?
 
Yes - you definitely can. The External Behavior Tree reference allows you to assign the tree in the editor.
 
I see that you can assign it in the "inspector" tab in the behavior tree editor, but I was actually wondering if it was possible to assign it without editing the tree.

For example: I create an external tree called GoblinBehaviorTree that has a reference tree node for the attack. Now I create three goblin objects with behavior components and I assign the same GoblinBehaviorTree tree to all three. Now I want to two of these to have Attack1 for their attack tree, and the other one to have Attack2 for it's attack tree. Is that possible?
 
Top