How do i spawn multiple instances of an AI controlled character?

hello,

first off let me tell you that i am quite new to the unreal engine. what i have created so far is the following:

  • a third person character able to move around / fire a projectile

  • a zombie character

the zombie char was created following a bot tutorial on youtube. i modified it since my zombie is a melee character while the tutorial was for a shooting one. it uses an ai controller, a blackboard, a behaviour tree and several tasks and decorators.

when i place it in the world it all works as expected, the zombie can sense me through ai perception and will then move to my position, when nearby he will start punching. when i move away he will follow until i break the line of sight. then he will go back to patrolling between waypoints.

the problem now is: if i pull a second instance of this zombie into the level ( or if i spawn it via blueprint, makes no difference ) it all breaks down. if a zombie sees me it will start to move to me, then go to partrol mode, then move to me and so on. to me it looks like both zombies are using the same state variable, so because one sees me it goes to the move state, but the other one doesn’t so it switches to patrol mode.

when i open the behaviour tree in debug mode i can see that there are multiple instances of the ai controller. yet both jump wildly between states.

i hope someone can help or clarify what is going on here and how i can fix it.

thanks

It’s been a while since I worked with AI but isn’t there somewhere in the blackboard or the behavior tree itself a setting making specific keys global for all actors using that behavior tree. A bool meaning by toggling it off each AI will have their own.

Hey,

Like Erasio pointed out it looks like you forgot to set the Instance synced bool to false, if this is true these properties will be global.
You can find it in the BlackboardData of your AI:

Hope this helps :slight_smile:
Elias

big thanks to the both of you!

that fixed my problem and now it works as expected. once again thank you very much =)