We’ve implemented a seamless server travel in our game. A volume triggers as a player step into a room which spins up a new server, a subsystem on the client creates a new PlayerController, GameState, and Pawn that gets swapped to after it connects to the new server.
The subsystem caches the LocalPlayer and when the new PlayerController is created, set calls SetPlayer(CachedLocalPlayer). This needs to be done before all of the client-side components are created and start communicating with the server.
However on NetConnection.cpp:4958 in the function UNetConnection::HandleClientPlayer( APlayerController *PC, UNetConnection* NetConnection ) it detaches the old PlayerController if the new PC and the old PlayerController are on the same level.
But it doesn’t check if LocalPlayer->PlayerController and PC are the same object - which is the case in our game. Since we SetPlayer() very early in the new PlayerController’s lifecycle.
// Detach old player if it’s in the same level.
check(LocalPlayer);
if( LocalPlayer->PlayerController && LocalPlayer->PlayerController->GetLevel() == PC->GetLevel())
{
I’ve added a check by updating NetConnection.cpp like so:
// Detach old player if it’s in the same level.
check(LocalPlayer);
if( LocalPlayer->PlayerController && LocalPlayer->PlayerController != PC && LocalPlayer->PlayerController->GetLevel() == PC->GetLevel())
{
This works a lot better for us, but I just wanted to ask if this is a proper fix - and if it’s something that should find itself moving upstreams.