I’m working on a rather simple project to familiarize myself with multiplayer a bit better. I have a fairly good understanding of how replication and server authority works - they’re not new concepts for me. However I’m struggling real hard trying to get seamless travel to work as expected.
Basically I have a lobby where the players can choose their role, basically Role 1 or Role 2. These roles are then saved in their PlayerState - which should persist.
Once both players have chosen a role, a countdown starts and the server then performs ServerTravel - this is all working as intended so far.
Upon reaching the new map however, only the client’s player state is kept. The host’s state is getting reset every single time, even if I override the OnReset event.
I tried moving this logic to the player controller, but it has the exact same behavior. I know I could potentially use the GameInstance for this, but that seems a bit impractical considering the player state should persist. I’ve also tried using the OverrideWith event inside the player state to get the old values, but the results are still the same.
It’s a simple matter of being able to choose their role in the lobby, then upon loading the actual gameplay map - assign their chosen roles. I simply can’t figure out why the host’s playerstate is either not updating or being reset.
I tried verifying their roles before initiating ServerTravel to ensure their roles were set properly, and they are. It’s always after the ServerTravel that the host loses his data.
This project is on 4.25.3, results are the exact same for a packaged build played on two separate computers as well.
Any suggestions?
Edit:
Some more context.
Gamemodes for Lobby, Transition and Gameplay are all set to use Seamless Travel. All 3 gamemodes use the same player state which has a PlayerRole enum variable set to editable and replicated.
Edit 2:
I tried to put together a quick repro project, you can download it here. Seems to reproduce the same effect as I have in my main project.
This is how I playtest;
- Uncheck Run Under One Process
- Set Play Net Mode to Play as Client
- Set Number of Players to 2
- In the standalone instance of the game, go to Multiplayer -> Host Game
- In the PIE instance of the game, go to Multiplayer -> Join Game -> Connect
- Move each player into a separate zone
- Watch the printed messages for the server, host’s state has been reset