void AGameModeBase::HandleSeamlessTravelPlayer(AController*& C) { // Default behavior is to spawn new controllers and copy data APlayerController* PC = Cast<APlayerController>(C); if (PC && PC->Player) { // We need to spawn a new PlayerController to replace the old one APlayerController* NewPC = SpawnPlayerController(PC->IsLocalPlayerController() ? ROLE_SimulatedProxy : ROLE_AutonomousProxy, PC->GetFocalLocation(), PC->GetControlRotation()); if (NewPC) { PC->SeamlessTravelTo(NewPC); NewPC->SeamlessTravelFrom(PC); SwapPlayerControllers(PC, NewPC); PC = NewPC; C = NewPC; } else { UE_LOG(LogGameMode, Warning, TEXT("Failed to spawn new PlayerController for %s (old class %s)"), *PC->GetHumanReadableName(), *PC->GetClass()->GetName()); PC->Destroy(); return; } } InitSeamlessTravelPlayer(C); // Initialize hud and other player details, shared with PostLogin GenericPlayerInitialization(C); if (PC) { // This may spawn the player pawn if the game is in progress HandleStartingNewPlayer(PC); } }