Attach a controller to a spawned AI inside a BT Task[SOLVED]

I have been roaming the forums for answers. I know you choose Spawn Actor from Class, set your enemy to spawn, it’s respective BT, then you spawn the default controller. Well, this doesn’t work.

Then I found elsewhere that you need to tick Run physics with no controller, and set movement mode to falling in begin play in your Enemy, however, that still doesn’t work.

I have also tried spawnActor, then spawn the controller, then possess, but, once again, it doesn’t work.

Am I doing something wrong? Can anyone lead me to the right path? Many thanks in advance.

there’s also an option that ‘spawn AI from class’ and includes the character and behavior tree to run. in your character, you can set the default AIcontroller to run, and in your AIcontroller, on beginplay verify that run behavior tree is set to the correct behavior tree, but this last part might be redundant.

I usually just set the “Auto Possess AI” property in the Pawn class from “Placed in World” to “Placed in World or Spawned”, then just run the behavior tree from the Pawn’s Possessed event. This wouldn’t work if you’re using the same class for both AI and Player controllers, but should otherwise.

Thanks for the answers so far, but the issue seems to be that it doesn’t work because I am trying to spawn them inside a task inside a Behavior Tree. I tried it in the level blueprint with the same nodes and they worked, so I believe its not possible to spawn AI from inside another Behavior tree?

you can…sorta. not in the task itself, but let’s say you have a Task_SpawnAI then in that task call a function in a game mode or anywhere you want that will actually spawn the AI.

Well thought, many thanks! :smiley: