1
\$\begingroup\$

I'm attempting to copy/modify the MultiplayerShootout project's multiplayer functionality for my own project. I'm running into issues when Player 2 joins a running session though. Finding it very hard to debug multiplayer stuff because you have to run it in standalone and toggling breakpoints doesn't seem to be illustrating any issues.

Here's the issue: https://youtu.be/270p4YS36Pw

The first player to search for a game hosts a game, then the OnPostLogin in the GameMode fires and calls the ClientPostLogin event in the PlayerController, then the PlayerController calls the RespawnPlayer event inside the GameMode which spawns and possesses the character. The second player finds a session and joins it, but the server is not spawning a character for them on the other PlayerStart.

The logic is very much similar to the MultiplayerShootout, but I have modified it in the following ways:

The 1v1 button searches for sessions, and if it can't find any it will automatically host a session.

The ClientPostLogin event on the PlayerController and the RespawnPlayer event on the GameMode accepts a Selected Character (Actor class) variable. This is so I can get the player to select their character before they matchmake and pass it through to the PlayerController and then GameMode for spawning purposes. Would really appreciate some help on this, been stuck on it for a while.

Here's some of the blueprint scripting to make sense of it:

OnPostLogin event in the GameMode OnPostLogin event in the GameMode

ClientPostLogin in the PlayerController ClientPostLogin in the PlayerController

RespawnPlayer event in the GameMode RespawnPlayer event in the GameMode

1v1 button released event in the PlayScreen Widget 1v1 button released event in the PlayScreen Widget

HostGame event in the GameInstance
HostGame event in the GameInstance

JoinGame event in the GameInstance JoinGame event in the GameInstance

Edit: I'm using UEngine version 4.24.3

\$\endgroup\$
1
  • 1
    \$\begingroup\$ You don't need to write "FIXED" into the title of your question. When you solved your problem yourself, then just accept your answer and the question will appear as answered. \$\endgroup\$
    – Philipp
    Jul 15 '20 at 8:59
0
\$\begingroup\$

Moving the RespawnPlayerEvent into the PlayerController fixed this. I think it had to do with the inability for the second client who joins (who is not the server host) to call a function in the GameMode (which only exists on the server).

RespawnPlayerEvent inside PlayerController ClientPostLogin inside PlayerController

To sum it up:

  • The player selects a character and stores the actor class in a variable inside the GameInstance (this is because the GameInstance does not lose information upon traveling to different maps).
  • When a player joins/hosts a server the OnPostLogin event fires, passing the PlayerController and firing the ClientPostLogin event inside the PlayerController.
  • The PlayerController then gets the Selected Character variable from the GameInstance and passes it on to the RespawnPlayerEvent which is also inside the PlayerController.
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.