Transfer PlayerState data during seamless travel

Hi!
I have alot of problem getting data transfered in PlayerState from my lobby-level to my game-level using seamless servertravel.

  1. Host game: Create session ( in GameInstance - Blueprints)

  2. Openlevel - lobby ( in GameInstance - Blueprints)

  3. Add some values on server side to PlayerState (FString replicated)

  4. Seamless travel to Game

    if (HasAuthority())
    {
    GetWorld()->GetAuthGameMode()->bUseSeamlessTravel = true;
    GetWorld()->ServerTravel(FString(“/Game/ThirdPerson/Maps/Game”), true);
    }

  5. My player state overrides CopyProperties

    void AMyPlayerState::CopyProperties(class APlayerState* PlayerState)
    {
    APlayerState::CopyProperties(PlayerState);

     AMyPlayerState* MyPlayerState = Cast<AMyPlayerState>(PlayerState);
     
     if (MyPlayerState)
     {
     	MyPlayerState->TestName = TestName;		
     }
    

    }

But then both PlayerStates (InParam and Current) is wiped, ie no values which i had before the travel is set

  1. When i debug the existing instances of PlayerStates in the different maps i can see that,

In lobby before semaless travel: MyPlayerstate_2

After semaless travel and in properties i have: MyPlayerstate_4 and MyPlayerstate_5

So, where did PlayerState_3 go? Which problably had my data set

I reproduced this in a from scratch project as well.

1 Like

Bumping the post

Bumping the post :slight_smile:

Would really appreciate if some1 at Epic took a look at this. Or how could i get some help otherwise, open for suggestions.

Best regards

Consider the matter bumped

Ok, after a second look at ShooterGame i solved the problem, apperently you must set the variabledefinition as below:

UPROPERTY(BlueprintReadOnly, Replicated, Category = "Preplan")
		TArray<UMinionDataWrapper*> MinionDataArray;	

void AShooterPlayerState::CopyProperties(class APlayerState* PlayerState)
{
	APlayerState::CopyProperties(PlayerState);

	if (PlayerState != nullptr)
	{
		AShooterPlayerState* ShooterPlayerState = Cast<AShooterPlayerState>(PlayerState);		
		if (ShooterPlayerState)
		{			
			
			ShooterPlayerState->MinionDataArray = MinionDataArray;			
			
		}
		
	}
}

Think the BlueprintReadOnly is the key here, hope some1else can get helped by this finding,

cheers!

2 Likes

Hi ,
So my understanding of SeamlessTravel is mostly based on this:

I don’t think its the BlueprintReadOnly, but the fact that PlayerState is “persisted” across a seamless travel. You can add more Actors to persist by putting it in the AGameMode::GetSeamlessTravelActorList()

My understanding is that Actors “persisted” across a SeamlessTravel is NOT the same Actor in memory; the persisted actor has its “count” increased (the _1, _13, etc), and certain data is copied across. In The case of PlayerState, there is an existing CopyProperties function which allows you to specify what to copy

So did you try it out in the PlayerState/CopyProperties?
I’ve read everything there is about this and it still didn’t work. I used BlueprintReadWrite on my UPROPERTY and it didn’t work, you are welcomed to try it and then we can compare results.

You can persist Actors by implementing GameMode::GetSeamlessTravelActorList() , “putting it” is kind of misdirected as it may be interpretated as to use a Set-function, override is better to use in this case imo.

Cheers!

Thank you for sharing the solution. I have the same problem in a blueprint only project and this is really bad :-(. I can override CopyProperties in Blueprint, but it does not work. It will copy the properties, but for some reason not use the copy, as you wrote above. It seems that I need to implement PlayerState in C++.

It is important to note that this only works for seamless travel. And since seamless travel does not work in the editor (up until at least UE 4.22), this will not work while debugging using the editor!

You can use this in standalone (and thus the packaged build only!)

Seamless travel works now in PIE as of 5.1 you just need to set this in as a console variable
net.AllowPIESeamlessTravel=1

You can also set console variables using the new Console variable plugin (Beta)

Hope this helps