This did work in the editor (did not test in standalone game)
FooGameMode.h
UCLASS(minimalapi)
class AFooGameMode : public AGameMode
{
GENERATED_BODY()
public:
AFooGameMode();
virtual UClass *GetDefaultPawnClassForController_Implementation(AController *InController) override;
public:
UPROPERTY(EditDefaultsOnly)
TSubclassOf<ACharacter> SecondClass;
};
FooGameMode.cpp
UClass*AFooGameMode::GetDefaultPawnClassForController_Implementation(AController* InController)
{
if (NumPlayers <= 1 && SecondClass)
return SecondClass;
return Super::GetDefaultPawnClassForController_Implementation(InController);
}
Now in the editor create a GameMode blueprint that inherets FooGameMode and set it as default game mode.
Edit(Top Left corner)->Project Settings->Maps & Modes(Under Project on the left)
(Under Default Modes)
set Default GameMode & Global Default Server Game Mode (press the down arrow)