SeamlessTravel: How does server know all clients are ready?

I’m trying to build a lobby/game configuration system that gathers users, and when the configuration is ready, start the game.
I call SeamlessTravel on the server as a console command.
I presume that all clients will follow this server and also load the target map.

However, how do I, on the server, know that all players have actually connected and are ready/replicating?
I was thinking I could have each client send a to-server RPC when they start playing the level.
However, if I wait for a message from a client, then if a client is faster at loading a map than the server, then the clients may send the message before the server is ready.

Or does “seamless travel” just take care of all this for me?

1 Like

Without just copying a pasting this answers everything… Travelling in Multiplayer | Unreal Engine Documentation

Have you checked into the advanced sessions plugin if your using bp’s only? It gives you some additonal BP exposed OSS stuff but not a check “are all clients connected” AFAIK

youd probably want to have a game instance or player state boolean make sure everyone is in the level somehow maybe a get all start points and check if characters are overlapping, thats be my half-■■■■■ solution.

Let me know if this helps
Don’t forget to accept an answer that best clears your question up or answers it so when the community finds your question in the future via search/google they know exactly what you did to fix it/get it going.

Thank you. I had read that documentation already. Unfortunately, it doesn’t answer my question. In fact, it claims that ServerTravel is asynchronous, and thus it just makes the problem even worse – the server may have some clients connected that are on a previous map and haven’t yet received the notification to travel to the transition map (and then the new map.)

Is there any callback in the GameMode or level or whatever when a player has completed transitioning?

The only other solution I can think of includes the map telling the player (on the client) to set a “my currently loaded map” string on the player state. The server could then poll this state for all players until it’s the correct value for all the players. That seems … inelegant. Given that the server already knows when all players have traveled to the transition map, there has to be some notification I can tie into.

So, the answer I’m going with, is polling “Num Travelling Players” until it goes to zero.
It’s not perfect, but I can make it work.
(Draw-backs includes that entities will be ticking while I’m still having the loading screen down.)

This is from my GameState blueprint; SetupPlayers is called from Event Begin Play in the Level Blueprint.

I am also struggling with this, and I could not find any event which marks when it is done. However, this workaround does not work for me, because it seems even if “Num Travelling Players” is 0, there is still some replication ongoing. I can only make it work through an additional delay, which feels bad.

Hi!
I have a system with a dedicated server and had the problem of knowing when the clients are ready to receive replication etc.
My solution is that I replicate a test variable (an integer) and then let the client answer on On_Rep to the server “ClientIsReady” (server, reliable). When all the clients are ready i setup all relevant data from my preplan phase.

It works perfect and is stable.

I know this question is fairly old but I noticed that there isn’t any answer here that doesn’t rely on a poll.

I think the best way to tackle (as you mention in a comment) is via a GameMode callback.

Unreal’s client-server model is focused around the concepts of worlds and their GameModes. A dedicated server will sit listening on a particular map with a GameMode loaded. When connections happen, the GameMode gets the chance to reject or accept connections with PreLogin, available when deriving AGameModeBase in C++ (this is probably also available in BP but I’m not sure of it).

After PreLogin is accepted we get PostLogin which will happen for you in the Lobby and I guess this is what is how you are detecting to initiate the Seamless Travel.

I think the callback that you are looking for is called HandleStartingNewPlayer. According to the GameMode docs, it is:

Called after PostLogin or after seamless travel, this can be overridden in Blueprint to change what happens to a new player. By default, it will create a pawn for the player.

So overriding this will give the server a notification after a seamless travel has occurred.


Sam Pattuzzi - Co-instructor on the Udemy’s Best Selling Unreal Course

1 Like