Tell Nodecraft Studio when you are changing levels (non-seamless travel only)

If your game exclusively uses seamless travel while players are connected to your server, you can skip this section.

In Unreal Engine if you do not use seamless travel when transitioning between levels, PlayerControllers will be disconnected from your server and will then reconnect more or less immediately. When these players reconnect to your server, their join token will have expired (since it was used when they first connected) which is what we use to validate players when they connect. As such, we need to keep track of which players have already been verified before moving to the next level.

In order to do this, you just need to call

void UNodecraftGameServerManager::SavePlayerVerificationData(UWorld* World)

In the Lyra example project we do this by overriding the AGameMode::ProcessServerTravel function, like so.

void ALyraGameMode::ProcessServerTravel(const FString& URL, bool bAbsolute)
{
	UNodecraftGameServerManager::Get().SavePlayerVerificationData(GetWorld());
	Super::ProcessServerTravel(URL, bAbsolute);
}

⚠️

It is extremely important that if you call SavePlayerVerificationData at a different time than in the above example, you do so before player controllers are disconnected from the server. Otherwise, players will attempt verification when reconnecting your server with an expired join token and be ejected from the server.

🛠️

Soon you will have the option of simply inheriting from A NodecraftNonSeamlessGameMode instead of writing the above code yourself.