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.
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.
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.
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.
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.
See also
- Concept: Ability System Component
- Concept: Multiplayer and Prediction