I have two AI characters with different behavior logic. So there are two AI blueprints for two types of AI characters, two controllers, two Behavior trees and blackboards. I want to use one BB, one BT with switching bool variable to address different logic. I don’t know what would be the best practice. How to unite two controllers that would control two different characters’ logic. I would leave them separate if I didn’t want the two AI characters to switch roles inside the game.
Or, should i keep them separate and go around to “pretend” they switched places. Any experienced opinions?
It’s usually what works best for you.
You could have one big tree and dynamically inject smaller trees at runtime using RunBehaviorDynamic. Or you could create smaller reusable Sub trees and reuse them across behavior trees using RunBehavior.
Another thing you could also do is to have one common controller and derive child controllers from it. You can then assign different behavior trees for different controller subclasses at startup time (You would usually assign Behavior Trees in AIController subclasses).
You mostly don’t want to combine one controller for two different characters. You could follow the approach up and create two controllers from a common subcontroller or something along those lines. Same thing applies to the trees.
You can reuse blackboards across multiple Behavior Trees. And again, you can extend them, if needed.
Hope this helps.