Download

Can't spawn more than 1 player

I’d like to spawn a player for each client window but I’m keep getting this error:
Error: Failed to Create Player: Maximum number of players (1) already created. Unable to create more.

void AMyGameModeBase::SpawnPlayers()

{
//spawn a player pawn for each playerstates in the game in the PlayerStarter

for (int i = 0; i < NumberOfPlayers; ++i)
{
	AMyPlayerController* NewPlayer = Cast<AMyPlayerController>(UGameplayStatics::CreatePlayer(GetWorld(), i, true));
	if (NewPlayer)
	{
		UE_LOG(LogTemp, Warning, TEXT("%i Controller is Spawned"), i);
		AMyPawn* NewPawn = GetWorld()->SpawnActor<AMyPawn>(DefaultPawnClass, PlayerStarts[i]->GetActorLocation(), PlayerStarts[i]->GetActorRotation());
		NewPlayer->Possess(NewPawn);
	}
	else
	{
		UE_LOG(LogTemp, Warning, TEXT("NewPlayer was null"));
	}
}

}

I saw that the Game Instance limits the split screen players to 1 but I don’t want it to use split screen.

Could anybody shed some light on it please?

Just curious. Why do this? Unreal spawns a player for each client automatically.