How can I change the level for all connected clients in a multiplayer game?

How can I change the level for all connected clients in a multiplayer game? Preferably in blueprints…

I currently try to multicast a “Open level” node with the new level name. The level gets loaded on all clients but the clients seem to be not in the same level (they do not see each other)

Also I would like to pass on some information, how do I do this in blueprints?

Hey Rouby,

This is similar to a question asked previously, seen here: How do I switch maps with a host and bring the clients along? - Multiplayer & Networking - Epic Developer Community Forums

Hope that helps!

-Steve

I tried that command, but the clients dont load the map?
The console spams this line:

LogNet: NotifyAcceptingConnection: Server Chess refused

Also there are some hints, that the old gamemode gets carried over?

LogNet: Browse: 127.0.0.1//Game/Maps/DesertArena?game=/Game/Blueprints/ChessGameMode.ChessGameMode_C

Just to clarify, you’re running that command from the server only, correct?

Yes, I have a “switch has authority” inbefore and am sending the command to reliably execute on the server (on my game state blueprint)

If I play without a dedicated server, only the (listen)server jumps to the next level, if that helps

Any news on this topic?

Tell me a little more about what is going on.

You start a game with mapname?listen and several clients join somehow? Via open someipaddr on the console window?

Now you have several clients connected to an existing server and you want to have the map switch?

You should be using seamless travel (bUseSeamlessTravel set on the AGameMode class) and then do this

FString UrlString = TEXT("nextmapname?otheroptionsyouwant");
GetWorld()->ServerTravel(UrlString);

This will keep connections alive for all existing clients, load a transition map, unload your old map, then load the new map. This keeps high memory watermarks from causing Out Of Memory conditions.

To do seamless travel you need some settings in DefaultEngine.ini

[/Script/EngineSettings.GameMapsSettings]
GameDefaultMap=/Game/Maps/MyGameEntry
ServerDefaultMap=/Game/Maps/MyGameEntry
GlobalDefaultGameMode="/Script/MyGame.MyGameMode"
GlobalDefaultServerGameMode="/Script/MyGame.MyGameMode"
TransitionMap=/Game/Maps/MyGameTransition

The transition map can be anything; a blank, empty map is best. You can actually have things load and display during the map transition (like the Gears of War scoreboard with particles floating in the background), which will go away when the new map is loaded. I don’t know much about how the content is setup for that, but an empty map should suffice for now.

Clients shouldn’t have to do anything special during seamless travel. If you see

LogNet: NotifyAcceptingConnection: Server Chess refused

It’s most likely because seamless travel is off, the clients were disconnected, and they are trying to get back in. If you “hard travel” back to another world and didn’t include the ?listen then the new server destination won’t be setup to receive clients. Seamless travel handles this for you.

Also, during seamless travel there is a garbage collection step that takes place between loading the new world and unloading the old. We make sure nothing references the old world (causing a memory leak). If you have any AActors or UObjects that refer to the old UWorld that get carried over to the new map then you’ll get an assert about the old world still staying around. Hopefully this won’t be the case for you, but if it does we can talk about that too.

I hope this helps. This stuff isn’t that straightforward and documentation is on the way.

Hi, thanks for the in-depth answer.

I am currently doing all my game-logic inside of blueprints. Is it possible to do this seamless travel (or any travel at all) via blueprints at this moment (or anytime)?

I start my debug-session with two clients via the play-in-editor feature with Num. clients set to “2” and checked “Run Dedicated Server”.

Sorry for the delay.

I was looking through the GameplayStatics to see if there was a travel function exposed to blueprints. I’m told there is, but I haven’t found it yet. I see OpenLevel, but I’m not sure that is going to do what you want. It calls SetClientTravel which would move a client to another server, but I don’t believe it will take a server and bring clients along with it. You could try that for now and see what happens.

It is already on the roadmap to make travel/multiplayer a lot more friendly to blueprints.

I did try to use OpenLevel before I used the execute console command method. It didnt travel with clients / reset the connection.

I did implement the steps you mentioned in your first post, but when I execute the Travel-function the editor crashes:

Also I get this message in my log files

[2014.06.16-01.20.17:112][975]LogWindows: World /Game/Maps/DesertArena.DesertArena not cleaned up by garbage collection!
World /Game/Maps/DesertArena.DesertArena [target] (root) (standalone)

I couldnt reply to your top-post somehow…

The crash you mention in the pastebin I’m not sure what that is because it is in some custom code, ServerMovePieceToField_Implementation().

You’d have to tell me what engine function you are calling on line chessgamestate.cpp:108

However, the log you provide above indicates a common problem when dealing with seamless travel and is an indication of a potential memory leak. This is why we assert there. Some AActor or UObject has a reference chain that leads back to the old UWorld. When this happens, the entire world would fail to unload through garbage collection.

After that message above should be a reference chain list from the world to the offending object. You may need to clear out a UObject pointer reference or use a weak pointer on some object to break the chain.

Im just calling GetWorld()->ServerTravel(UrlString);

Is this the reference-graph you mentioned? If so I cant tell what I need to fix…

Can you tell me a little bit more about the transition process. What map do you start in, what is your transition map name, what is your destination map name? Are they all different, if only to test. You can go A->transition->A. But shouldn’t try to go A->A directly.

I start in a simple map with a chessboard and the pieces, at some point my gamestate get the server-replicated call from one client to move a piece to a specific position, the gamestate then calls ServerTravel (to the arena-map)

I dont think I create any objects or actors that have pointers to the current map (chess-map)… how can I check this?

Start map : /Game/Maps/Chess

Transition map : /Game/Maps/TransitionToArena

Destination map: /Game/Maps/DesertArena

Im still stuck at the garbage collection error, can you please tell me more on what I should focus? Seamless travel still crashes the whole editor, normal travel works, but I would like to get my clients follow the server to the new map :confused:

Sorry, trying to stay on top of this, but GC bugs can be hard to track down sometimes.

Can you run your game outside the editor? Still using the editor binary, but with

UE4.exe YouGameName mapname?listen -game -log

and then do your travel. I would like to see if it’s something special about PIE or if the same GC problem occurs. There are ways to debug GC, I will probably need to ask for some assistance with people who know it better. The reference graph in your case isn’t very descriptive unfortunately.

Still working on this, I haven’t forgotten about you :slight_smile:

The new map is the one that is showing up in the error message, I didn’t notice that until just now. Our function may be missing something.

You are running within the editor right, loading Chess, clicking the PLAY button (what are you settings there?), then clicking something in your game that initiates the travel right?

Thanks :wink:

Yes im testing this all in the editor, I have it setup to run 2 clients (and tried with or without dedicated server) and the travel occures when I move a chesspiece onto a specific field.

Ok I’m going to work with QA to see if we can repro this. Our editor validation code is slightly different (and newer).

Have you tried running your game outside the editor? It might work just fine. Not a solution but a stopgap.