Object that maintain state across levels - Network

Hey guys, we use a proprietary network system in our project, and i need to maintain state of my initialized class across levels/maps.

Example:

  1. Map LoginMenu, client enters username and password, click login. Network class tries to login, maintain conected state with keep alive
  2. Client goes to map Game, and that class with active socket doesnt get cleaned.

Any tips?
Thanks

One place to start is with bUseSeamlessTravel in GameMode. If you set this flag it will keep network connections open when transferring maps, and will attempt to keep the same PlayerController objects, if the class doesn’t change. If you look at AGameMode::HandleSeamlessTravelPlayer you can see what it does to controllers during the map transfer. You can copy data accross in SeamlessTravelTo/from if you need to.

If you want to save persistent information on the client, a good place to put things is in a subclass of LocalPlayer. If you change the LocalPlayerClassName variable you can make it spawn a game specific subclass. Then, you can add whatever data you want to it. LocalPlayers get created at startup time (or when initializing controllers for multiplayer games) and stick around throughout the entire game, so it’s can be a useful place to put things.

Neither of these solutions are particularly simple or well exposed to blueprints, but they’re a good starting point and can be used to do what you want. We’re currently working to improve this situation and make it easier to use these systems.