How to use APlayerState::CopyProperties with seamless travel?

Hey, I’m working on an asymmetrical game (similar to dead by daylight), and I want to transfer the player’s role (enum) from the lobby to the game level. This role is used to determine which character to spawn for the player in the game level.

Is the copy process supposed to be a “two stop” logic? So I should copy first from Lobby to Transition Map, and then Transition Map to Gameplay Map? Because right now, I’m handling this as going from Lobby to Gameplay Map.

Here is the code, no errors, but the role is not transfered. Seamless travel is enabled on the lobby GameMode, and I’ve been testing it in Standalone mode. Thanks in advance!

UPROPERTY(Replicated, BlueprintReadOnly)
EPlayerRole PlayerRole;

void AHGameplayPlayerState::CopyProperties(APlayerState* PlayerState)

     AHLobbyPlayerState* PS = Cast<AHLobbyPlayerState>(PlayerState);
     if (ensure(PS))
          PlayerRole = PS->PlayerRole;

void AHGameplayPlayerState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const

     DOREPLIFETIME(AHGameplayPlayerState, PlayerRole);

It’s the other way around - CopyProperties is called on the old PlayerState, and the incoming argument is the new PlayerState.

Take a look at APlayerState::SeamlessTravelTo

@TheJamsh Sweet, it is working as expected now. Thank you so much!

NP’s - I had to check myself :smiley: Not the most obvious of function/parameter names…

@TheJamsh Can you answer me one more question real quick? Since seamless travel doesn’t disconnect players, how can I track if everyone is finished transitioning into the game level? Should I run a PlayerController iterator every second or so?

Edit: In GameModeBase I found the HandleSeamlessTravelPlayer method. As far as I understand this initializes the player after seamless traveling, so I think this will suffice.

Sure - AGameModeBase has a NumTravellingPlayers property (or something like that) you can check Server-side, to check if it’s still waiting for clients to transition into the map.

@TheJamsh Yeah, it is in AGameMode though, I’ll reimplement it or come up with something else. One thing that I still find weird, is that the widgets stay on the screen after seamless traveling. Shouldn’t they get destroyed with the HUD class?