Why one single behavior tree controls all instances of the Ai character? Why they don't have dedicated BT each?

I’ve followed the unreal tutorial about behaivour trees and I’ve managed to create it successfully. The AI actor does what is expected, if it sees me it will always try to follow me and arrive at my position.

Now I’ve duplicated the AI actor a couple of times in the scene and in theory each one of them should attempt to arrive at my position. but no. It appears like the Behaivour tree is controlling all of the duplicated actors at the same time and it fails.

Like there is only one master instance of Behavior tree for all Ai actors at the same time.

what I’m missing here? maybe there is some option to make the behavior tree duplicate with the same actor, be a separate instance?

ok so after a night of sleep I’ve found out that the tutorial on the unreal documentation is really basic and has a lot of flaws.

by adding more copies of the AI actor the behavior tree will work correctly only if the AI “see” the player first. Else if he notice the other AIs actors, the behavior tree will jump to the random move section even if the player is in front of him.

Before I’ve figured this out I’ve tried duplicating the AI Actor in the content browser just to see what happens.

Got another issue, inside a Behavior Task blueprint, the author of the tutorial made a cast to the main AI Actor.

Because now we have a different AI actor name the Behavior Tree is broken

This is an issue if one want to reuse behavior trees for different Ai Actors.

Anyone knows some online resources that goes in more detail on how to create the Behavior Trees to be reusable and not tight coupled with a particular Blueprint?

Ok, I’m talking to myself here lol.

So to avoid the casting problem one needs to use Blueprint Interfaces.

I’m new to all of this, obviously this may be something many already know.

This is the tutorial I’m talking about

to make it work first in the “Enemy_Character” blueprint, on the Character Movement component enable “Use Acceleration for Paths” this way the walk animation actually works.

then after you have followed the entire tutorial and all works for one AI do this.

create a blueprint interface called BPI_AI_Actor then inside add a function named “UpdateWalkSpeed” that have an input of type float called “NewWalkSpeed” Compile and save.

Open “Enemy_Character” blueprint and click on Class settings. Add the BPI_AI_Actor interface.

Try to compile, you get an error. This because we have already a function called “UpdateWalkSpeed” and that prevents the creation of the interface function. We need to delete the exiting function.

Go inside the “UpdateWalkSpeed” and copy the nodes that are there. Delete that function. Compile, now it works and in the graph view you will have a new red node. Paste the copied nodes and plug them in in this new red node that have the function name.

Now go inside both “BTT _ChasePlayer” and “BTT _ChasePlayer” and replace the cast to the Blueprint character to a cast to the BPI_AI_Actor interface. Plug all the nodes in as they were on the other cast node.

Now as long as the AI Actor blueprint implements BPI_AI_Actor the interface it doesn’t matter what name it has.

Interface implementation inside an AI Actor


Cast to interface not the actor blueprint class name

ok I’m done

1 Like

Interfaces are fine of course, but you should also look into inheritance, you could have left the base npc calls.
It’s not normal and I think it’s not recommended, to duplicate all the AI code every time you make a new enemy, you can just make a blueprint child and change only the cosmetic or override some function.

1 Like

Bro, thanks in advance for super duper clearly tutorial, but mine is still not working. The other instances still stuck, but the original still works fine, i am still figuring out why, i will post it when it gets solved


Just tweakinghere and there, found this “Update Nav Agent with Owners Collision”. Then it works as it should be!

I don’t recall that option, maybe it was on on my side? Or maybe is a new thing?