How to specify a pawn in a controller?

I can spawn pawns just fine. This is a matter of design.

I am creating an actor (spawn manager) off of my GameMode.
The spawn manager contains the specific aicontroller to use.
I got the aicontroller to return the specific (to that aicontroller/pawn) spawn points.

Now I want to be able to have

UClass* AAWGameModeBase::GetDefaultPawnClassForController_Implementation(AController* InController)

ask the controller what pawn to use.

I am wanting to do this to avoid having the game mode know about every custom controller and every pawn type.

This “works” when I cast to the specific controller and then specify the pawn class in the blueprint based off the game mode.

If I could just do the same thing with specifying the pawn off the controller based blueprint that would be great, but the pawn variable is always null.

Below is from UT. I want to have many different monsters without having to check for each one and add an entry for the BP pawn off the game mode blueprint.

UClass* AUTGameMode::GetDefaultPawnClassForController_Implementation(AController* InController)
{
	AUTMonsterAI* MonsterAI = Cast<AUTMonsterAI>(InController);
	return (MonsterAI != nullptr && MonsterAI->PawnClass != nullptr) ? *MonsterAI->PawnClass : Super::GetDefaultPawnClassForController_Implementation(InController);
}

I didn’t really want to go this route, but it is the cleanest I have so far. I hate having hardcoded paths to assets in my code, but it is better than the IF THEN ELSE mess.

When my NPC specific controller is constructed it gets a reference to the BP pawn and puts it in a protected variable at the parent class of my NPC controllers. Then I have a method in the base controller I override in the specific controller to return that BP.

It accomplishes cleaner code. Will look at removing the hard coded path later.

Followed this: Spawn Blueprint from C++ - Editor Scripting - Unreal Engine Forums