How-To: Persist Combat State Across Levels

Goal: keep buffs, cooldowns and attribute values across a ServerTravel instead of resetting the player every time they walk through a door.

Prerequisites
Quick Start.

How it works

A UCrimsonAbilityStateCarrierSubsystem (a game instance subsystem, so it outlives the world) holds a snapshot between levels. The old world stashes; the new world consumes.

Server-side only
The snapshot is authoritative state captured on the server. Clients receive the restored state through normal ASC replication - there is nothing to do on the client.

1. Choose what persists

Tag your effects with Crimson.Persistence.Persist to opt in, or Crimson.Persistence.DoNotPersist to opt out, then set the default policy in Project Settings -> Crimson -> Ability State Persistence.

Verify
The settings section lists your policy and the tag filters.

2. Stash and restore

Get Game Instance Subsystem (CrimsonAbilityStateCarrierSubsystem) then Stash Snapshot before travel and Consume Snapshot after the new level loads. Has Snapshot and Peek Snapshot let you check without consuming.

SaveGame is not Replicated
Restored values are applied on the server. If a value looks right on the server and stale on a client, the property is missing its replication - restoring does not replicate on your behalf.
Verify
Buff yourself, travel, and confirm the buff and its remaining duration survive. Then repeat with Play As Client and confirm the client sees the restored state too.

3. Effect-level persistence

UCrimsonEffectPersistenceComponent handles the per-effect bookkeeping if you want persistence without driving the carrier yourself. Add it to the actor that owns the ASC.

Verify
Effects tagged to persist survive travel with their remaining duration intact.

See also

  • Concept: Ability System Component
  • Concept: Multiplayer and Prediction