How-To: Save Player Progression

Goal: persist per-player progression (stat tags, and your own attributes) using the CrimsonCore player-state integration.

Prerequisites
(CrimsonCore - requires all Crimson plugins. `CrimsonCore` is free to download, but compiles only with all Crimson plugins installed. Using `CrimsonSaveSystem` alone? Make your own player state a saveable system with Quick Start: Saveable Systems and give it a fragment with How-To: Custom Fragments & Versioning - the result is the same.) Your player state derives from ACrimsonPlayerState. It already implements ICrimsonSaveableSystem, registers itself server-side, and saves its stat tags and squad id as a Player-scoped fragment. It also carries a save adapter component per system - skill trees, ability state, inventory - each of which owns its own fragment and its own file, so one system failing to save takes nothing else with it.

1. Stat tags persist automatically

Anything you store via AddStatTagStack on the player state is captured and restored per player with no extra code - it rides in the fragment's SavedStatTags.

Verify
Add a stat tag, save, reload - the count is restored on the correct player key. In split saves, each player's tags stay separate.

2. Add your own data (e.g. attributes)

Subclass the fragment (UCrimsonPlayerStateSaveFragment) to add fields, then write and read them in the player-state hooks Gather Player Save Data / Restore Player Save Data. See How-To: Custom Fragments & Versioning for how the fragment subclass is created.

Create a Blueprint child of ACrimsonPlayerState (CrimsonCore - requires all Crimson plugins). In My Blueprint -> Functions, open the Override dropdown and pick Gather Player Save Data, then Restore Player Save Data. Each drops a red event node into the Event Graph carrying a Fragment input pin.

In Gather Player Save Data: Cast To your fragment Blueprint on the Fragment pin, then Set your own fields on the cast result - stat tags and squad id are already written by the base class, so add only what it does not cover. In Restore Player Save Data: cast the same way and read the fields back onto the player state. Both run on the server only; the restored values reach the owning client through normal replication.

Server authority
The player state registers and saves only on the server. GAS attribute values must be applied server-side; they replicate to the owning client normally.

See also

  • How-To: Custom Fragments & Versioning - subclass the fragment for structured data
  • Concept: Multiplayer & Save Scopes - how player keys work