Where does AIController spawning occur?

Im working to implement a custom spawnpoint system, where I can setup a variety of spawn conditions and actions and events based on variables set within the spawnpoint.

But I cant find where the AIControllers get spawned into a match so I can figure out how to hook into it.

Where does AIController spawning occur?

AI controller gets spawned as part of SpawnDefaultController call and it spawns an instance of a class indicated by Pawn.AIControllerClass. The easiest way to hook up a dynamic controller class selection here via blueprint is to use SpawnAIFromClass, and via C++ just override APawn::SpawnDefaultController and do whatever you need.

Cheers,

–mieszko

I guess that is useful for setting variables in the Controller at spawn.

But Im looking to change what, how many, and when it is spawned based on settings in the spawnpoint. I could just straight spawn it in the gamemode tick behind some checks against those spawnpoint variables, but I want to spawn it in using existing methods so as not to fight against existing functions trying to unexpectedly do things to the controller at spawn, and so not to interfere with existing tracking ect…

I was originally wondering how the gamemode would know how many AI to spawn in the world at start, and where I would go to hook into that(and use as an example/basis for other more complex implementation).

But it sounds like such a thing doesn’t exist?
In that case I guess I would just create my own.

Sounds like you just want to implement a spawning system (like you say), so just do it. Not sure what’s stopping you. Like I said, the AIController for a pawn is spawned with SpawnDefaultController call, which is called from APawn::PostInitializeComponents, which answers your original questions.

If that’s not what you need, then could you be more specific?

That’s correct, no AI get’s spawned “by default” until you tell the game to do so.