Skip to content

Save Game support

Krzysiek Justyński edited this page Nov 11, 2022 · 11 revisions

Intial SaveGame support is available since version 1.1.

Flow Graph plugs into Unreal's SaveGame system. If you haven't used it yet, read "Saving and Loading Your Game" docs.

You control which properties are included in SaveGame by marking C++ properties with the SaveGame specifier. Or by ticking the SaveGame checkbox in the blueprint editor.

What to look for?

  • FlowSave.h. Active graphs are serialized to the UFlowSaveGame object which simply extends the engine's USaveGame. That allows you to integrate Flow Graph into your SaveGame setup easily.
  • UFlowSubsystem keeps a registry of all active Flow Graphs at the given moment. That's why it also contains methods providing SaveGame support. You need to call methods like OnGameSaved, and OnGameLoaded. These are accessible from blueprints.
  • UFlowNode class provides overridable events OnSave and OnLoad, so you can custom SaveGame logic to any node, i.e. restore Timer with "RemainingTime" value read from SaveGame. Check UFlowNode_Timer class for reference.
  • UFlowAsset and UFlowComponent exposes similar OnSave and OnLoad events, so you should be able to customize SaveGame logic in every plugin's class that's involved in SaveGame operations.

Signal Modes features provides a solution for modifying Flow Graphs post-launch, once players already have SaveGames with serialized graph state.

Quick sample

You can find a quick example of integrating Flow into your SaveGame setup in the FlowSolo demo project. Here's simple C++ classes related to this.

Note: You might need to call UFlowSubsystem::LoadRootFlow manually on your Root Flow owners if you're loading a game while the world is already active. Flow Component does automatically call LoadRootFlow only on BeginPlay! Supporting in-game loading is up to you.

Support for graphs not instantiated from the Flow Component

It's possible to create Root Flow for any UObject owner, i.e. Player Controller or some subsystem. However, in this case, you need to support Save/Load logic a bit on your own.

  • You might need to call UFlowSubsystem::LoadRootFlow on this custom owner (not including Flow Component) after deserializing SaveGame with UFlowSubsystem::OnGameLoaded. Look at the sample code linked above, you need to iterate on owners if they don't include Flow Component's logic.
  • If your Root Flow is created on UObject owner that doesn't belong to the world (Game Instance or its subsystem), you need to set the bWorldBound property on your Flow Asset to False.