Save and Load a Match
This guide adds a Save and a Load button to a standalone game. A save stores the exact simulation state and the camera. Loading it continues the match from the saved tick.
Save and Load work only in a standalone game. In a network match they return false, because loading rewinds one machine and would desync the others. To understand what a save holds and what it can be loaded into, read Saves and Replays.
1. Make the camera savable
Section titled “1. Make the camera savable”The save stores the camera through the pawn the player controls. The Sein Camera Pawn supports it. If you use your own pawn, open it, then Class Settings > Interfaces > Add, and choose Sein Snapshot Camera Provider. Implement its two events:
- Capture Camera State writes the pivot location, yaw, pitch and zoom distance into the struct, and sets Has State to true.
- Restore Camera State applies them, and does nothing when Has State is false.
Without the interface the match still saves and loads. The camera just stays where it is.
2. Add the Save button
Section titled “2. Add the Save button”In the pause menu widget, bind the Save button’s On Clicked to Save Match, with a File Name such as Slot1.
Branch on the return value: show “Saved” on true, and “Could not save” on false. A relative name goes to Saved/Snapshots, and .seinsnapshot is added when the name has no file type.
3. Add the Load button
Section titled “3. Add the Load button”Bind the Load button’s On Clicked to Load Match with the same File Name, and branch on the result.
On true, close the menu. The simulation has already resumed from the saved tick. On false, the match goes on as it was.
Call Load Match once the gameplay map is running, from a widget or the Game Mode. A save loads only on the map it was made on, so the map is opened first by your own flow.
4. List the saves
Section titled “4. List the saves”The nodes take a file name. They do not list files. Keep the names yourself in an Unreal Save Game object: add a name when the player saves, show the names in a list, and pass the chosen one to Load Match. The Save Game holds presentation data such as slot labels and play time. It is not part of the match.
5. Rebuild what the save does not hold
Section titled “5. Rebuild what the save does not hold”A save holds the simulation. It does not hold actors, widgets, particles or sounds. After a load the framework reconciles unit actors with the loaded state and then calls On Presentation Refresh on each. Set each unit’s look from its data there: construction group, weapon model, health bar. Do not play one-shot effects there. See Presentation and Visual Events.
Your own widgets read view models every frame, so they follow the loaded state without extra work.
What your own data must do
Section titled “What your own data must do”Anything the simulation owns is saved automatically, if it follows these rules.
| You have | Where it goes | Included |
|---|---|---|
| A number a unit has | A SeinARTS Actor Component variable on the unit Blueprint, as Fixed Point or Integer | Yes |
| A number a player has | A component on the Player State | Yes |
| A number the match has | A component on the Game State | Yes |
| A number an ability or effect keeps | A variable on the ability or effect Blueprint | Yes |
| A new kind of simulation data | A C++ component struct, see Add a Simulation System in C++ | Yes |
| Module-level state in C++ | A struct registered with USeinWorldSubsystem::RegisterStateBlock before the match starts |
Yes |
| A menu choice, camera setting or key binding | Your own Save Game object | No, and it should not be |
| Particles, sounds, widgets, animation state | Rebuilt from the simulation | No |
Simulation data may hold:
- Booleans, bytes, integers, names, enums and class references.
- Structs marked deterministic, which includes the fixed-point types.
- Text and references to textures, meshes, materials, sounds and effects. These go in the presentation stream and are saved exactly, but never checksummed.
- A
floatordoubleonly when it is marked Presentation. On a Blueprint variable, check Presentation in its details. Visuals may read it. The simulation must not.
It may not hold actor or component references, or delegates in a component or module struct. A Blueprint compile warns about a float the simulation cannot hold, and a match with such a field in its data will not start. Asset validation also flags a String variable on a simulation Blueprint.
Test it
Section titled “Test it”- Start a standalone match and note a distinctive state, such as 3 Soldiers and 500 Minerals.
- In one Blueprint event, run these four steps in order: Execute Console Command
Sein.Net.DumpState, Save MatchTest, Load MatchTest, Execute Console CommandSein.Net.DumpState. All four run in the same frame, so the simulation does not advance between them. - Open the log. The two
[SeinNet]lines show the sameTickand the sameChecksum. The match is restored exactly. - Play on for 30 seconds. Spend the Minerals and lose a Soldier. Click Load. The Soldier is back, the Minerals return, and the camera returns to where it was.
- Quit and relaunch. Open the same map, then Load. It loads.
- In a packaged game, rebuild with a changed Blueprint and try the old file. It must refuse, and the log says the file was made by a different build. The editor records its content as “Uncooked”, so it does not notice Blueprint edits.
You can do the same from the console with Sein.Net.DumpSnapshot <name> and Sein.Net.LoadSnapshot <name>.
Troubleshooting
Section titled “Troubleshooting”Save Match and Load Match write the reason to the log as Save Match: ... or Load Match: ....
| Message or symptom | Cause |
|---|---|
| “works in standalone games only” | You are in a network match. |
| “state version … does not match” | The save came from another framework version. |
| “made by build … this is …” | The game was rebuilt or the project version changed since the save. Simulation content changed. |
| “simulation settings differ from this build’s” | A setting that affects the simulation changed. |
| “made on map … this is …” | Open the map the save was made on before you load. |
| “Could not read …” | The file name or folder is wrong. A relative name is under Saved/Snapshots. |
| “different set of simulation modules” | The save came from a build with different SeinARTS modules. |
| “captured only on the game thread, between simulation ticks” | You called Save Match from inside the simulation. Call it from a widget or controller. |
| Camera does not return | The pawn does not implement Sein Snapshot Camera Provider, or Restore Camera State ignores the data. |
| Units load but look wrong | The look is set only by events. Set it from data in On Presentation Refresh as well. |
| Compile or start fails naming a field | A float or actor reference sits in simulation data. Change its type or mark a float Presentation. |