Making my AI more compact

Hello!

I am working on my first project in Unreal, i will have around 20 npcs with their own routine, looks, house location, they go to work, eat, etc…

I made a master BP with the basic information, and a child for each NPC, i would like to use one AI BP for all and adjust the routine based on the pawn variables, so far so good, the pawn adjust the variables on the AI BP.

I face a problem when i need to fire a event from a task or ai to the pawn, for this i would need to cast to the pawn.

What would be the best solution for this?

I think about spawn the NPC´s from one BP, or just building 20 ai´s and behavior trees, but i would like to keep the 20 individual BP´s to fine adjust everyone. About performance, would have a different using 20 different behavior trees?

Thanks for any help!

This sounds like something you could use an interface for. That way, you could just call the interface to tell the NPCs to “do something,” but each individual NPC may interpret “doing something” differently. :slight_smile:

Thanks for the reply!

Indeed the interface could help this, would be a way to set controlled pawn in the task BP as a variable so only the correct one would fire?

Just to clarify, this event is to change clothes, so if the npc go to work, this task will be together with the vector.

I will try something later, from the controlled pawn i can add a tag, i will try to add a tag like “changestyle”, fire the interface, on the pawn validate the tag, back in the task remove the tag, and finish it. Will report if this works, or will use any other idea :slight_smile:
Thanks again!

I’m not sure I quite understand how your interactions are set up.
I do know that interfaces work in most cases when you want different actors to do different things from the same type of call.

I made a very simple system, is just switch, 1 work, 2 casual etc… Each number change the body mesh, nothing fancy.

In the end, i don´t even have to use the tag… i think i need to learn more about interfaces hahahahaha just the interface works like a charm, i don´t even had to make the branch to validate the tag, don´t know why, but they only fire the interface in the controlled pawn, important is that this works, so i will have 19 less tasks BP to adjust :slight_smile:

Thanks for the help!