How to control individual AI

I have set up an AI system with behaviour trees and an AI Controller. I am trying to make it so that a “squad leader” can issue orders to its teammates. e.g attack that actor, move there.
I can make the squad leader actor give orders to all the AI in the scene, by using my function that sets the attack target and makes them attack. But i want only specific actors to follow the order.
My question is, how would I give a single AI an order instead of all AI being affected by it?
Thanks.

Hey @Indexofgames!

My thought here would be to add all of your squad to an array, however you’d like to do that is up to you and is very unique to whatever it is you’re doing. Regardless, you need to get those squadmates into an array on your squad leader!

Now, using that array that holds all of the squadmates, you can do things like “ForEach” and then “GetDistance” from the actor to find out which one is the closest, get that index from the Array (which will output one of your squadmates) and then tell THAT one to run your attack event. :slight_smile:
I know it’s kind of complicated but once you get it down for one type of command it will translate to the other commands with minimal changes!

Let us know if you have any issues!

First I suggest using Interface calls for the commands, it is safest way, second you can do sphere trace to get all the actors in certain radius and send the command to them or to one of them as Mind-Brain suggested.