Spawn character with AIController / BT Doesn't work

I am having quite a hard time understanding how to spawn a character with an AI controller

I created a spawner blueprint whose task is only to spawn these items.
The spawner tries to spawn characters with an AIController , inside a nav mesh.
The AIController then tries to run a BT that (at the moment) tries to only move the character to a random location (created whene the item is spawned)

If i drag the character in the viewport, the thing works fine, if i use the spawner, it doesn’t.

Spawner:

AI Controller

NOTE: I also tried with the event “OnPossess” instead ,as another user suggested

Behavior Tree:

Debug wich shows that the behavior tree is actually there

What am i doing wrong ?

UPDATE:
In the project i have 1 character dragged manually, and 2 spawned from the spawner.
For some reason about 5% of the times ONE of the 2 spawned actually moves.

The core issue here is that your spawned AI pawns don’t get their AI controllers spawned. That’s the default behavior. You can change that by modifying your pawn’s AutoPossessAI to PlacedInWorldOrSpawned.

Alternatively you can just call SpawnDefaultController on your pawn, just after spawning.

Or you can simply use SpawnAIFromClass blueprint function that will save you a lot of hassle :smiley:

Cheers,

–mieszko

Hi, thank you for your support, i am actually using SpawnAIFromClass, you can see how i used it in the first screenshot.
i don’t understand this odd behavior
Edit: i am sorry, only now i noticed that the quality is awful :frowning: the node is the last on the right

Yeah, I haven’t noticed that, sorry.

Your debug screenshot shows that the AI controller is indeed spawned and the BT is running the “move” task. Maybe it’s just movement issue, not the AI/BT thing? Have you tried using visual log to debug the issue? Maybe Pawns start too far above navmesh and can’t find their location on it? I could use more info here :slight_smile:

Hi, thank you again for your help; if the visual log is the thing you open with the apostrophe key,yes, i did, but nothing useful happened; the navmesh i created was huge, just to be sure that the pawns were inside it.
I hadn’t time to further delve into the issue due to job times :frowning: i believe it is somethign related to the BT, because sometimes it works; i don’t know exactly how to debug the BT

Vislog is a tool you summon with vislog console command, or with Window → Developer Tools → Visual Log. If the debug screenshot you posted is from a “not working AI” scenario, then that’s no BT issue. But I need more data.

Thank you again,
I would say that after re-making the bt and the controllers (and tasks) the original problem of this thread is now resolved,still don’t know why though. i must now solve the further problems that came after that :smiley:

SpawnDefaultController works for me. Thanks!