Skip to main content
Flow Core Documentation
Menu

Flow Stats

Capture and Restore Flow Stats

Capture mutable runtime state, change it, and restore one coherent in-memory snapshot.

Audience
Gameplay designers and developers
Time
10 minutes
Requires
Flow Core installed with the 7. Stats example
Modules
Flow Stats
On this page

Goal

Use the supplied 7. Stats controls to capture mutable runtime state, make several changes, and restore the captured result. No scene or asset edits are required.

Prerequisites

  • Import the Flow Core examples.
  • Open the supplied 7. Stats scene.
  • Keep the Stats controls and live values visible in the Game view.

This walkthrough demonstrates an in-memory FlowStatsSnapshot. It is not a disk save and does not survive leaving Play Mode.

What You Will Build

ValueCapturedAfter mutationRestored
Health Current604060
Strength Base101210
Attack Power Effective252925

Attack Power is calculated as Strength × 2 + Weapon Power, where Weapon Power is 5. A Snapshot stores every Stat’s mutable Base, including Attack Power’s own Base. It does not store Formula Contribution, Raw, or Effective; Restore returns Strength Base to 10 and recalculates Attack Power Effective as 25.

Steps

1. Capture the starting state

  1. Open the scene named 7. Stats.
  2. Enter Play Mode.
  3. Confirm Health is 60 / 100, Strength is 10, and Attack Power is 25.
  4. Select Capture Snapshot.
  5. Confirm the status line reads Last Event: Snapshot captured.

2. Mutate several values

  1. Select Damage 10 twice. Health becomes 40 / 100.
  2. Select Strength +1 twice. Strength becomes 12.
  3. Confirm Attack Power recalculates to 29.

These changes belong to the initialized Flow Stats owner. The shared Profile and definition assets remain unchanged.

The running Stats example after capturing, damaging Health to 40, and increasing Strength to 12.

3. Restore the snapshot

Select Restore Snapshot once.

The sample calls TryRestoreSnapshot and then reports Last Event: Snapshot restored. Health returns to 60, Strength Base returns to 10, and recalculation returns Attack Power to 25.

The restored Stats snapshot with Health at 60, Strength at 10, Attack Power at 25, and the restored status message.

Verify the Result

What a Default Snapshot Means

A default capture can include:

  • instance Display Name;
  • mutable Stat Base values;
  • Resource Current values;
  • active Status Effects whose Persist field is enabled, including their stack and timing state.

Formula contributions, Raw and Effective values, modifiers, normalized values, and Resource boundaries are recalculated or retained by the receiving runtime rather than treated as separately authored save values.

Boundaries to Keep Explicit

  • Restore requires an initialized runtime when Stat, Resource, or Effect state is included.
  • The receiving Flow Stats must use the matching Profile Stable ID.
  • Resource Current is clamped to the receiving runtime’s cached bounds.
  • Effects with Persist disabled are intentionally absent.
  • The example controller stores its snapshot only in memory. Use the optional persistence integration when data must cross sessions.

Common Mistakes

SymptomCheck
Restore Snapshot does nothingCapture first and remain in the same Play Mode session.
Restore reports a Profile mismatchRestore into a runtime using the same logical Profile identity.
A derived Stat looks staleConfirm the Formula dependencies are valid; derived values are recalculated after restore.
A Resource restores at a boundaryThe receiving runtime clamps Current against its cached Minimum and Maximum.
An Effect is missingEnable Persist on Effects that belong in snapshots before they are applied.
The snapshot disappears after Play ModeThe sample holds an in-memory object, not a serialized save file.

What You Built

You completed a capture–mutate–restore loop and verified that one snapshot restores coherent mutable Stats state while calculated values are recomputed.