Game crashes when restarting AAIController

I’m at my wits end. So any help at all is appreciated

I have a subclass of AAIController and a subcless of my character which represents a Bot. Up until now they work great, had no issues with them. I’ve been dragging them into the scene with auto possess AI set so they get a controller. It works fine, no issues.

So I’m setting up a way for the GameMode to spawn controllers and then Bots automatically so I don’t need to drag them into the scene. And when the game starts like this, it crashes.

I’ve put hours and hours into debugging this and learning about it and what I’ve discovered is during the SpawnActor call for the pawn (In RestartPlayer) the physics body is created, and the game crashes because the Actor’s SkeletalMesh is NULL. It doesn’t exist. For some strange reason. Check out what I have so far:

When the game is waiting to start controllers are created:

void ABBGameMode::HandleMatchIsWaitingToStart()

	for (int32 i = 0; i < NumOfBots; ++i)
		FActorSpawnParameters SpawnInfo;
		SpawnInfo.Instigator = Instigator;

		ABBAIController* AIC = GetWorld()->SpawnActor<ABBAIController>(SpawnInfo);

		int32 NameID = FMath::RandRange(0, BotNames.Num() - 1);

No problems here. Then when the match has started I run through the controllers calling RestartPlayer on each.

void ABBGameMode::HandleMatchHasStarted()

	for (FConstControllerIterator It = GetWorld()->GetControllerIterator(); It; ++It)
		ABBAIController* AIPC = Cast<ABBAIController>(*It);
		if (AIPC && AIPC->GetPawn() == NULL)

What’s bizzare is in the superclass restart player is called on the APlayerControllers, so it’s not like I can’t do it at this stage in the game. I tried swapping the default bot pawn class to various things, to no effect.

I’m pulling my hair out and throwing stuff at the wall. Please provide some input.

I eventually figured out what this was. So for anyone else landing here, it was because when the player is restarted the game mode looks for the appropriate class with the function GetDefaultPawnClassForController(). This was returning the base C++ class without a skeletal mesh set, rather then the blueprint class because in the constructor of the AIController I set the DefaultBotClass to AMyBot::StaticClass(); Overriding what I’d set in blueprints.