Do different AI Controllers use different Behavior Trees?

Hi, I have a doubt with the concept of Behavior Trees. Let’s say I have two bots each using an instance of a custom AI Controller class. Now this AI controller class runs a behavior tree at event begin play. So in this scenario, are these 2 AI Controllers using separate instances of Behavior Trees?

Every instance, regardless of their controller, runs a new instance of a behaviour tree. If they just referenced the same instance they would all do the same thing at the same time which would most likely result in weird behaviour.

If you think about it - two agents are in different part of the map, one sees the player and tries to run away, but because they share the same brain the other runs too - off a ledge or into a wall etc.

Thanks SirYakalot, yea that makes sense.

That’s not exactly true.

Every AI using BT has a dedicated BT component, but as long as they’re using a single BT asset there’s a lot of things being shared across all of its users. That’s why we have a concept of “Instanced” nodes, because by default nodes are “skeletons” which means are being run for multiple users and just identify particular AI by UBehaviorTreeComponent instance that’s always being passed as a parameter to any BT node call.

This scales a lot better with number of AIs using the same BT asset.

Thanks Mieszko for the in-depth reply on how the underlying system works.