$npx -y skills add teixasalone/UnrealEngine5-Skills --skill ue5-save-load-replicationUE5.6/UE5.7 save/load and multiplayer replication workflow for gameplay systems. Use when requests involve SaveGame schema design, serialization, restore pipelines, RepNotify handling, RPC entry points, and server-authoritative validation.
| 1 | # Quick Start |
| 2 | - Define what must persist and what must replicate. |
| 3 | - Separate local save state from network runtime state. |
| 4 | - Output data schema, save flow, load flow, and net flow. |
| 5 | |
| 6 | # UE5.7 API Anchors |
| 7 | - Save pipeline anchors: |
| 8 | - `USaveGame` |
| 9 | - `UGameplayStatics::CreateSaveGameObject(...)` |
| 10 | - `UGameplayStatics::SaveGameToSlot(...)`, `LoadGameFromSlot(...)` |
| 11 | - `UGameplayStatics::AsyncSaveGameToSlot(...)`, `AsyncLoadGameFromSlot(...)` |
| 12 | - Replication anchors: |
| 13 | - `GetLifetimeReplicatedProps(...)` |
| 14 | - `DOREPLIFETIME(...)` |
| 15 | - `ReplicatedUsing=OnRep_*` |
| 16 | - `UFUNCTION(Server/Client/NetMulticast, ...)` |
| 17 | - Authority anchors: |
| 18 | - server-authoritative mutation path |
| 19 | - client requests routed through validated server RPC entry points |
| 20 | |
| 21 | # State Contract |
| 22 | - Every state field must be classified as one of: |
| 23 | - Persistent-only (SaveGame, not replicated) |
| 24 | - Replicated-only (runtime sync, not persisted) |
| 25 | - Persistent + replicated (authoritative state with save restore) |
| 26 | - Every persisted schema must include: |
| 27 | - explicit version integer |
| 28 | - stable identifiers/keys (avoid index-based implicit ordering) |
| 29 | - migration behavior for older versions |
| 30 | - Every replicated field must define: |
| 31 | - replication condition or scope |
| 32 | - `OnRep_*` behavior on clients |
| 33 | - server write ownership |
| 34 | |
| 35 | # Workflow |
| 36 | ## 1) Partition State |
| 37 | - Identify gameplay state by ownership: local player, world/shared, match/session. |
| 38 | - Split ephemeral runtime values from persistent values. |
| 39 | - Mark authoritative write path for each field. |
| 40 | |
| 41 | ## 2) Save Schema |
| 42 | - Define save structs/objects with explicit schema version. |
| 43 | - Use stable keys/IDs for actors, components, and inventory-like entries. |
| 44 | - Include optional migration metadata for backward compatibility. |
| 45 | |
| 46 | ## 3) Save Pipeline |
| 47 | - Gather runtime state into save schema in deterministic order. |
| 48 | - Write through sync or async slot APIs based on latency sensitivity. |
| 49 | - Return structured save result (success, failure reason, version used). |
| 50 | |
| 51 | ## 4) Load and Restore Pipeline |
| 52 | - Load save object, validate version, run migration if needed. |
| 53 | - Apply restore in dependency-safe order (owners before dependents). |
| 54 | - Resolve missing assets/entities with explicit fallback policy. |
| 55 | |
| 56 | ## 5) Replication Pipeline |
| 57 | - Replicate only client-visible runtime state. |
| 58 | - Register replicated properties with `DOREPLIFETIME(...)`. |
| 59 | - Use `OnRep_*` for client-side reconstruction/UI refresh, not authority writes. |
| 60 | |
| 61 | ## 6) RPC Authority Pipeline |
| 62 | - Use client->server RPC for requested actions. |
| 63 | - Validate payloads on server before mutating replicated state. |
| 64 | - Broadcast resulting state via replication/NetMulticast only when needed. |
| 65 | |
| 66 | # Constraints |
| 67 | - Server is source of truth for replicated gameplay state. |
| 68 | - Validate all client-requested actions before applying state changes. |
| 69 | - Keep SaveGame schema versionable; avoid fragile implicit ordering. |
| 70 | - Do not assume single-player behavior in multiplayer code paths. |
| 71 | - Keep restore process idempotent where possible (safe to retry after partial failure). |
| 72 | - Avoid persisting transient network-only caches. |
| 73 | |
| 74 | # Failure Handling |
| 75 | - Symptom: load succeeds but gameplay state is inconsistent. |
| 76 | - Locate: restore ordering and missing dependency handling. |
| 77 | - Fix: apply owners/components/dependents in staged restore order with fallback defaults. |
| 78 | - Symptom: old save files break after update. |
| 79 | - Locate: schema version checks and migration path. |
| 80 | - Fix: add explicit migration per version or gate unsupported versions cleanly. |
| 81 | - Symptom: replicated value differs from saved value after reconnect. |
| 82 | - Locate: authority write path and restore timing vs replication timing. |
| 83 | - Fix: restore on authority first, then let replication propagate to clients. |
| 84 | - Symptom: `OnRep_*` spam causes frame spikes. |
| 85 | - Locate: frequent property churn and large payload replication. |
| 86 | - Fix: batch updates, replicate coarse state, derive fine state client-side. |
| 87 | - Symptom: client can trigger unauthorized state changes. |
| 88 | - Locate: RPC validation and authority checks. |
| 89 | - Fix: enforce server validation and reject invalid client payloads. |
| 90 | - Symptom: async save/load callbacks race with gameplay transitions. |
| 91 | - Locate: callback lifecycle and stale object references. |
| 92 | - Fix: guard callbacks with state tokens and world validity checks. |
| 93 | - Symptom: partial restore leaves orphaned actors/components. |
| 94 | - Locate: failure rollback path. |
| 95 | - Fix: stage restore transactions and cleanup created artifacts on failure. |
| 96 | |
| 97 | # Replication Ops |
| 98 | - Use `ReplicatedUsing` when client-side side effects are required. |
| 99 | - Use RPC only for intent transfer, not as persistent state storage. |
| 100 | - Use replication for authoritative state fan-out; use SaveGame for disk persistence. |
| 101 | - Never trust client-local save data as authoritat |