Running a bit on wits-end here, so apologies if the tone of this post is a bit harsh. Onto the problem…
We have a multiplayer game where N number of clients (players) connect into a "lobby, " configure their weapons etc, and the server then proceeds “in-game” when ready via a button click (which does a servertravel command).
We can see that the clients and the server successfully move to the new map. However, we are unable to figure out a “good” way to persist Unique player information from the lobby to in-game. Let me explain the problem with more detail:
Assuming both the lobby map L and the in-game map IG use the SAME PlayerController type:
- lobby step
Player 1 (host) chooses Weapon W1
Player 2 (client) chooses Weapon W2
we store this “somewhere”, I will get to the “somewheres” we have tried and what has happened.
- move from L to IG
when ready, Player 1 does a servertravel to IG
- load in-game assets and settings
upon map transition, the game mode / player controller / whatever should Spawn Actor / create the actual in-game assets and Weapon settings (player 1 → W1, player 2 → W2) for the associated player.
Sounds pretty basic. Here’s the problem: There does not seem to be any way to persist data-ownership information in any meaningful way across server level loads.
Here’s what we’ve tried and what has happened:
- store the data in the server’s GameInstanceBP since this should persist, and use a unique ID to identify the player controller in the in-game map and his associated weapon information
This doesn’t work because even though we are using the same PlayerController TYPE, the INSTANCES in L and IG are different. Therefore, any ID we set from the server in the lobby gets wiped out and reset in the client after servertravel. In other words, we loose all data-connectivity information.
- store the data directly as replicated into the client PlayerController
We were under the understanding (based on what we read on the web) that playerController persists accross levels. This turned out to be wrong. As seen in (1), the instances get wiped out and re-initialized, so we loose all the data.
What are we missing for this BASIC, BASIC multiplayer functionality to work? We just need some good way to either ensure that DESPITE level changes, there is a unique ID per client that we can depend on to re-associate data, OR persist the actual data across level changes. Is there a flag we are missing?
TL;DR
There doesn’t seem to be any good way to persist player information across multiplayer servertravel. This is a HUGE problem for multiplayer games.
I’m a little shocked at how poor documented / supported this basic thing for multiplayer games seems to be in UE4. I can’t find any documentation about say, being able to get my own IP (which we could use as a unique ID), or if there is anyone has any info they can provide, good documentation or examples would be really really appreciated.