Persisting Playerstates through serverTravel

Hey there, I was checking out this post with Josh Markiewicz talking about the matter,

and I’ve created my own playerstate and am leveraging CopyProperties on the playerstate
and performing a serverTravel, however, the client doesn’t seem to get his playerstate once the map changes.

Here are the relevant bits.

The player state cpp –

void ASpellBinderPlayerState::CopyProperties(APlayerState* PlayerState)
{
	Super::CopyProperties(PlayerState);

	ASpellBinderPlayerState* PState = Cast<ASpellBinderPlayerState>(PlayerState);

	if (PState)
	{
		PState->EquippedItemIds = EquippedItemIds;
	}
}

And the gameMode ServerTravel

void ASpellBinderGameMode::ServerTravel(FString FullyQualifiedLevelName)
{
	if (Role == ROLE_Authority)
	{
		UWorld* World = GetWorld();
		if (World)
		{
			bUseSeamlessTravel = true;
			World->ServerTravel(FullyQualifiedLevelName);
		}
	}
}

If I’m doing something fundamentally wrong, I’d appreciate a push in the right direction.

Hey, i think what you are doing should work, i managed to have player reconnect to the game and have the playerstate given back to them by simply overriding CopyProprieties. Are you sure that ASpellBinderPlayerState* PState = Cast(PlayerState); succeeds?

I added some additional logging and confirmed that the player state is valid, but it doesn’t look like the properties assigned persist.

So I ended up moving that stuff into a new project and testing, and it totally works so the problem is definitely elsewhere in my project. At least I’m headed in the right direction now, thanks :slight_smile:

This only works on the Server for me, All the server data will persist but the client data will not persist. Has anybody found a work around for this or a solution?