Persistent Player Data Across ServerTravel

Hi,
I am wondering if there is a good solution for persisting player data across ServerTravel yet. I’ve been reading around and I saw it was a possible future feature mentioned a while ago, but wondered if there was any progress. Ideally what I’m looking for is something like a GameInstance class that functions almost the same way for individual players.

Right now the best solution I can come up with is to store all my relevant data in an array in the GameInstance class, which seems totally unnecessary to me because it’s super convoluted to hook up some data I may need very early on when my player controllers are recreated coming out of the ServerTravel.

I’ve read this already, and it’s probably similar to a solution I’ll end up going with, but I was wondering if something more engine supported exists yet. It seems weird to me that it wouldn’t be well supported. It makes something as trivial as tracking score through multiple multiplayer matches way more difficult than it should be.

I feel like I must be missing something :confused:

is to store all my relevant data in an array in the GameInstance class

This is a fine solution. One thing to pay attention to is memory bloat over time due to new players joining/leaving. You’ll need to solve cleaning out that memory when you’ve detected that player has truly left and not just disconnected for the server travel.

Ideally what I’m looking for is something like a GameInstance class that functions almost the same way for individual players

This is not a good general solution because MP games can have hundreds or thousands of players on that server over time. That would be a huge memory burden, since GameInstance is created at startup and destroyed at shutdown.

I may need very early on when my player controllers are recreated coming out of the ServerTravel

PlayerControllers are created on the server where you’d have the data anyway. It would just replicate down to the client, so I think that is an okay way to go

A couple things to correct you on. I don’t need a PlayerInstance that persists forever. I need a PlayerInstance that persists for as long as the player is joined to the server. I don’t care what happens when they disconnect. The problem I have is that anytime you do ServerTravel PlayerControllers/PlayerStates (specifically states) are destroyed and recreated, but they are recreated from scratch instead of repopulated with their previous data.

If you have a custom PlayerController/PlayerState that you want to have some persistent data between level transitions, I can’t see a better way to do that than to manually save and load the data when I leave the old level/reenter the new level. It would be nice if there were a place we could store data for the duration of a player’s session without us having to do it manually.

This is handled fine with SeamlessTransition as CopyProperties is called when you do seamless transitions, but that doesn’t seem to happen when you do ServerTravel.

If, for example, I have a player with inventory, and I want them to have the same items in a new level, as far as I can tell I have to handle that manually in my GameInstance instead of just loading the new level and having my data still exist or get copied to the appropriate new object.

I’m investigating something, this might be a problem with something we implemented incorrectly because it looks like we should be doing a seamless travel :confused:

Sorry to answer my own question, but this problem was caused on our side. Somebody had modified our code so that servertravel was not working as expected. For anyone interested, PlayerState does function the way I describe when used with seamless travel.

Is this still relevant? I have a similar issue trying to update a replicated variable to the server from a client. I have relied on switch authority to differentiate between the client and server and although the behaviour of the server is correct, the server maintains its copy of the variable so replication works only on server.
I’m going to try an interface to get the controller id from player state but still not sure how to address the server when updating a variable from client.

You’re trying to get the player controller while doing a server travel?