I’m calling Server Travel on the end of a ‘match’ and we’re going into a ‘Post Game’ Lobby. However, when I grab the game state/player states, it seems the ‘Score’ and other variables have all been reset… How can I persist it? At the very least, I’d like to keep my PlayerStates between the two levels, and could recalculate game state info from the player states.
I’ve already overloaded the CopyProperties function in my custom player state!
My two maps have different Game Modes and different controllers if that matters…
In the past in my projects, I’ve had to use the GameInstance to store the scores on the server just before server travel so that I could access them in the next level and then use the server to send them to be displayed on the clients’ score screen.
Important to note you cannot use it in the editor because seamless travel does not work in the editor. Your variable cannot be “BlueprintReadWrite”. And you also need to enable seamless travel and that only works in standalone or packaged build.
UPROPERTY(BlueprintReadOnly, Replicated, Category = "Preplan")
Test = "Original Value";
void AShooterPlayerState::CopyProperties(class APlayerState* PlayerState)
{
Super::CopyProperties(PlayerState);
if (IsValid(PlayerState))
{
this->Test = "New Value";
AShooterPlayerState* ShooterPlayerState = Cast<AShooterPlayerState>(PlayerState);
if (ShooterPlayerState)
{
ShooterPlayerState->Test = this->Test;
}
}
}