Problem with spawning AI


When I spawn an AI via bueprint (class is AICharacter) it changes the AI’s name and the problem is that my level blueprint makes AI_1 follow me, but since I have spawned another AI, it has another name (AI_2) and thus doesnt follow me. Does anyone know how I can make all of the AIs follow me (event tick , simple move to actor) ?

If you’re doing what I think you’re doing, you do NOT want to be using the instanced name for any sort of level logic. As you can see, the instanced name changes for each instance of that object (this is done by design, every name must be unique).

What you should probably try to do instead is create a section within your behavior tree code (as either a service or a task) which grabs the nearest character of class type X and sets that as its ‘follow’ target. You should be able to spawn 100 AI controllers which all have the same behavior.

Also, you don’t need to activate the “simple move to” every single tick. Just call it once. It’s run on a separate thread of execution, similar to the “delay” node. It will complete once the character arrives at their destination or their path is blocked. If you call it every single tick, you’re telling the navigation system to solve the pathing solution every frame, which is a waste of CPU.

I’m very unexperienced with the behavior tree, could you illustrate what you mean with “which grabs the nearest character of class type X and sets that as its ‘follow’ target.” ?

Also, the blueprint is the AI blueprint, not the level blueprint if that wasn’t clear.