Seamless travel spawning players

I was experimenting with seamless travel for my MP game and I noticed the player actors are lost in the process I now spawn them in the gamemode like this:

void ABbGameMode::PostSeamlessTravel()
{
	Super::PostSeamlessTravel();

	for (FConstPlayerControllerIterator Iter(GetWorld()->GetPlayerControllerIterator()); Iter; ++Iter) 
	{
		SpawnPlayer(Iter->Get());
	}
}

This works but im wondering if this is the appropriate way to do it?

Thanks.

You can keep your actors by overriding the AGameModeBase::GetSeamlessTravelActorList (on server side) or the APlayerController::GetSeamlessTravelActorList (per client) methods and add the actors to the list of kept actors during seamless travel.

You will lose the connection between the controllers and the pawn though, as I state here, so you’ll have to re-possess the pawns after server travel, for instance by implementing AGameModeBase::HandleStartingNewPlayer_Implementation (this is called also when loading the first level)