ServerTravel + SeamlessTravel + new GameMode

Hello UE4 community once again.

I’ve been struggling with this problem for 2 days now and still no sight of a solution.
What I’m trying to do is make clients and the host travel from a game lobby (MultiplayerLobby_GameMode) to a new level (DefaultGame_GameMode). The trick is that I want the map to override the lobby’s gamemode and create different controllers and states. The host and clients travel to new level without a problem but the gamemode doesn’t change.

I’ve already tried to pass ?game=DefaultGameMode (alias) parameter in the URL like here:


FString URL = LevelName + FString(TEXT("?game=DefaultGame?listen"));
GetWorld()->GetAuthGameMode()->bUseSeamlessTravel = true;
GetWorld()->ServerTravel(URL, true, false);

Turning off SeamlessTravel seems to make traveling the way I want yet it acts differently.
With SeamlessTravel turned on the scheme is as follows: Lobby -> TransitionMap -> NewMap
With SeamlessTravel turned off: Lobby -> Still lobby for both sides -> Host freezes and changes level -> Clients freeze and change level after a second

Is this acceptable? What are negative sides of such transition?

Thank you in advance.

I may be wrong but i’m pretty sure this is how it works:

SeamlessTravel - you keep all connections active between host and clients. The host calls the travel, opens up the transition level so that it can begin to flush out the old map while loading in the new one and keeping remote calls up with clients, then each client tells the server when they’ve arrived in the new map and all goes from there.

non-seamless - The server kicks everyone, opens the new map and they all reconnect.

Now for how to do it for switching out game modes etc you must use the travel string.

for instance, i have LobbyGM and TDMGM_BP both inside Blueprints/GameModes/ and i want to open map_office as a listen server, my string would look like this:

FString URL = "/Game/Content/Maps/map_office?game=/Game/Blueprints/GameModes/TDMGM_BP.TDMGM_BP_C?listen";

an easier way to find out what the full string should be is by using (in blueprints) GetPathName() and print that out from any asset reference or do that in code GameMode()->GetDisplay so you could even break it down to this with the right data available:

UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Map Names")
TArray<FString> MapNames;

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Game Modes")
TArray<TSubclassOf<class AGameMode>> GameModes;

void travel(int32 selectedMap, int32 selectedGameMode, FString additionalOptions){
   FString URL = MapNames[selectedMap];
   URL += "?Game=" + GameModes[selectedGameMode];
   URL += "?listen";

hope that helps!

1 Like

Everything works now. Using the functions provided I made sure that my paths are OK. Also it turned out that SeamlessTravel doesn’t call PostLogin function in GameMode class where I’ve been storing my debug tests :smiley:
Thanks for help :slight_smile: