AGameModeBase::HandleSeamlessTravelPlayer
#include "GameFramework/GameModeBase.h"
Access: public
Specifiers: virtual
Description
Called server-side to reinitialize a player who survived seamless travel into the new level. Performs equivalent initialization to `PostLogin` but without repeating the full login handshake.
Caveats & Gotchas
- • The `C` parameter is a reference to a pointer — if the controller class changes the pointer may point to the newly spawned replacement PC after the function returns. Never cache the old pointer before calling super.
- • This is called from C++ after the server finishes loading the new level for each player that connected before the server. Players who join during travel go through normal `Login`/`PostLogin` instead.
- • `GenericPlayerInitialization` is invoked inside this call, which in turn may call `RestartPlayer`. Avoid double-spawning by checking `C->GetPawn()` if you also override `PostSeamlessTravel`.
Signature
virtual void HandleSeamlessTravelPlayer(AController*& C) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| C | AController*& | Reference to the controller being reinitialized. May be replaced if the controller class changes during the swap. | — |
Return Type
void Example
Restore player loadout after seamless travel C++
void AMyGameMode::HandleSeamlessTravelPlayer(AController*& C)
{
// Save loadout before super potentially swaps the controller
TArray<FItemData> SavedLoadout;
if (AMyPlayerController* OldPC = Cast<AMyPlayerController>(C))
{
SavedLoadout = OldPC->CurrentLoadout;
}
Super::HandleSeamlessTravelPlayer(C); // C may now point to a new PC
if (AMyPlayerController* NewPC = Cast<AMyPlayerController>(C))
{
NewPC->CurrentLoadout = SavedLoadout;
}
} See Also
Version History
Introduced in: 4.14
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?