What is the best way to keep data between levels for multiple local player?

Hi,
What i try to achieve, is a local couch game with multiple players with multiple gamepads on the same PC/Console viewed from the same camera (not split-screen). The problem is:
How can i keep the data between levels, for example:
First i show a level where everybody can select their character and after on the next level the real game begins. I have to keep the selected character data for every player between levels.

I tried to find the answer for this question in many places. I found more options, but none of them seem perfect for me.

  1. Seamless travel and keep in PlayerState - Seems the obvious answer, but for seamless travel i have to use ServerTravel which is for multiplayer Server/Client architecture. It’s not an overkill? I don’t have clients, only one game instance no network connections. Or i’m just overthink and this is the answer for this type of problems, and the ServerTravel name just a bit misleading?
  2. GameInstance - It can work, but it sounds good only for single user scenarios. Obviously i can keep every user data in there, but i think it’s a bit hacky solution. Thats why i have PlayerState object for every player, to keep player related data there, not in the GameInstance.
  3. Store and load from config file in filesystem - The worst of all. :smile: Use the persistent storage to pass data between two temporary objects in the memory… Every cell in my body protests against it.
  4. Something other ???

I know, all of the above solutions can work. But i would like to know the correct answer, the Epic preferred way to solve this. Not a working hacky solution.

Thank you!

Hey there @szabot0412! If the game is only local, I wouldn’t consider GameInstance to be too hacky. It’s often the preferred method for local only games, an is often where saving and loading logic tends to live. Generally this is how I go about projects that won’t have any online components. “Global” variables are often bad practice in situations where there’s more than one writer and observer, but a locally multiplayer game only is basically the same as a singleplayer game for all practical purposes.

Seamless travel is fine for the method as well, even when not using network functions directly in the engine, you’re often already interacting with network functions. I would usually go this method and keep the data persistent with the players. This also helps if in the future the game does well locally and you may want to introduce multiplayer in any capacity.

1 Like

Thank you for the detailed description @SupportiveEntity,

I think i will go with the Seamless travel.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.