How-To: Persist a Level Actor
Goal: go beyond the basics and control how a saveable level actor behaves when it is destroyed - stay gone, or respawn from the level - and understand the runtime-vs-placed distinction.
ICrimsonSaveableActor and its state is marked SaveGame. An active save slot exists. This page picks up from there.Implementing ICrimsonSaveableActor and marking fields SaveGame is the whole opt-in - see Quick Start: World Actors for the images and code. Everything below is optional refinement on top of that.
1. Destruction is tracked automatically
The world subsystem listens for actor destruction on the server (including Destroy() and lifespan expiry), so a deleted saveable actor stays deleted with no manual call. A runtime-spawned actor simply has its save entry removed. A placed (level) actor reloads from the map every session, so a tiny GUID-only tombstone is written to keep it gone.
Destroy(). OnActorDestroyed(this) is an optional manual hook (e.g. to force an immediate flush with bSaveWorldStateAfterEveryChange). See the full matrix in Concept: World State & Identity.2. (Optional) Let a destroyed placed actor respawn
By default a destroyed placed actor never comes back. To make it respawn from the level after deletion instead, override ShouldRespawnAfterDestroyed to return true. (Runtime-spawned actors ignore this - once destroyed they simply stop being saved.)
Replicated (or RepNotify). Full explanation: Concept: Multiplayer & Player Scoping.See also
- How-To: Save Cross-Object References - persist pointers between saved actors
- How-To: Configure Auto-Saving - control when world state is captured and flushed
- Concept: World State & Identity - the capture, identity, and deletion model