[Multiplayer] How to trigger client event from Game Mode ?

Hello !

I’m trying to understand Multiplayer interaction, but some logics don’t run like I expect…In a listen-server session, a player Host and a second one joins the sessions. I do that with the Game Instance and work fine.

***ThirdPersonCharacter : ***

When the last player joins, ED does his job. I want now all players change Level (Order To Travel).

***ThirdPersonCharacter : ***
Pawn2.jpg

The Game Mode searches all players and sends Travel Event (Open Level).

***GameMode : ***

But, Game Mode sends Travel Event Twice to the server… Clients never receive the order.

It will be nice if someone got a idea !

Hi…

Using the client-server model (I don’t know about the dedicated server method)… You only need to call “Open Level” once - on the client-server (the client running/hosting the server). Basically on whichever client is running the server you call “Create Session” to create a new session, then on whichever client is going to be a remote client you call “Find Session” then “Join Session” which when successful will automatically join the client-server session and open its level. If you then want to open a new level (for example move from the lobby menu level to a gameplay level), all you need to do is call “Open Level” in the client-server Game Instance blueprint and it will open the new level… All remote clients that are part of the session will automatically close their levels and follow the client-server to the new level.

Note: When calling “Open Level” this will destroy the current Game Mode instance on the server and also all Player Controllers and Player States on both server and client, and then create new instances of them for the new level.

  • “Game Mode sends Travel Event Twice to the server… Clients never receive the order.”

When creating a client-server networked game, under the hood the server actually creates a local ‘proxy’ instance of the Player Controller for each player connected to the session to act as a “mailbox” for when communicating with remote clients. So when sending a message from the server to client, the server Game Mode actually sends this message to the local ‘proxy’ version of the Player Controller first, which then forwards this to the remote client version of the Player Controller.

I think the reason your client never receives the order is because you called Open Level on it, which probably de-synched it with the client-servers session…

Note: Looking at your code, you should also really do the Create/Find/Join Session and Open Level in your Game Instance as this is the only permanent object/instance that doesn’t get destroyed during the Open Level process

Thanks #Mach45 for the precisions! (I found the problem: the session is created - with Advanced Sessions Plugin - , but pawns don’t see each other…)

Awesome… gl

Ridiculous, I know, sorry about that. I wasn’t testing with 2 computers, only with editor and the results are very different…