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

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

B

Cast to interface not the actor blueprint class name

ok I’m done

1 Like