Networking¶
Every GASPALS system works on a listen server with clients. This page summarizes what replicates and how, so you can extend the systems without breaking it. Blueprint-only replication follows a few patterns, used throughout.
Patterns¶
Owner predicts, server confirms. The owning client applies a change immediately, then tells the server with a reliable Server RPC. The server sets a replicated variable, and other machines apply it in its RepNotify. Equipment, overlays and the camera perspective work this way.
Movement goes through the movement component. On the Mover pawn, anything that affects movement is part of the input command the owner sends: cover data, crouch, gait, ragdoll requests. Mover simulates it on the owner and the server and replays it on simulated proxies, so no extra replication is needed. On the CMC pawn, the owner shapes its acceleration, which the CMC replicates (p.EnableCharacterAccelerationReplication=1), and extra state travels in RPCs and replicated variables.
Montages play where they must. Root-motion montages (traversal, interactions, get-ups) are played on the server and the owner. Mover syncs a server-played montage to simulated proxies; the CMC replicates root-motion montages itself.
Cosmetics on every machine. Visual reactions (ragdoll physics profiles, sounds, first-person visibility) run on every machine from replicated state or mode changes, not from RPCs.
By system¶
| System | What replicates | How |
|---|---|---|
| Locomotion (Mover) | Movement, crouch, gait, rotation mode | Mover input commands with Network Prediction (DefaultNetworkPrediction.ini). Simulated proxies get the inputs (bSyncInputsForSimProxy). |
| Locomotion (CMC) | Movement, crouch | The CMC. The input state (CharacterInputState) is sent to the server with an RPC and replicated to others. |
| Cover (Mover) | Cover state | Part of the Mover input (S_CoverState). |
| Cover (CMC) | Cover state, facing | Owner-shaped acceleration, plus a 20 Hz server RPC (ServerUpdateCover) and replicated cover state applied on other machines. |
| Aim from cover | Result only | Runs on the owner; others see position, crouch and facing. |
| Equipment | Selected item | Replicated with RepNotify; every machine spawns the item locally. Client sends a reliable Server RPC. |
| Overlay | Overlay pose and body | Replicated with RepNotify; reliable Server RPC from clients. |
| Camera | Perspective | Server RPC; replicated to other machines (skip owner). Style and shoulder are local. |
| First person | Nothing | Owner-only meshes; other players see the third-person character. |
| Traversal | The traversal action | Owner predicts, reliable Server RPC with the result, server plays it; Mover and CMC sync the montage to others. The server does not replay it for a pawn it controls locally, so a listen-server host, a standalone player or a server AI starts each traversal once. |
| Ragdoll (CMC) | Start and stop, impulses | Reliable Server RPC, then a reliable multicast. An impulse applied on the server (ApplyRagdollImpulse) is multicast so every machine pushes its own copy of the ragdoll; one applied on a client pushes only its local copy. |
| Ragdoll (Mover pawn) | Enter, exit, roll, get-up choice | Mover input (S_MoverCustomInputs_Ragdoll), with the injury state replicated. Remote ragdolls are pulled toward the replicated capsule. |
| Takedowns, shoves | The interaction | Client predicts its own montage and asks the server, which validates and multicasts. The server rejects requests that don't include the requester or whose participants are out of range. |
| Visual override | The character class | Replicated with RepNotify on the manager component. |
| Pawn switch | The pawn class | Server RPC from the controller; the game mode respawns players. |
Testing multiplayer¶
- Open the options menu next to the Play button and, under Multiplayer Options, set Number of Players to 2 and Net Mode to Play As Listen Server.
- Test on both pawns (N), since they replicate differently.
- Watch the client and the server windows: equipment, overlays, cover, traversal and ragdoll should look the same on both.
- For the Mover pawn,
np.PrintReconciles 1prints prediction corrections. A handful at events like a takedown is expected; continuous corrections are not. - Use Network Emulation (in the editor's Play settings) with some latency and packet loss to see how the prediction holds up.
Rules for your own additions¶
- Mover: change movement only through the input command and transitions.
QueueNextModefrom gameplay code runs on one machine only. - Never call RPCs every frame for continuous state; send it in the movement input (Mover) or at a fixed rate (the CMC cover sends 20 times a second).
- CMC: a state that changes movement settings (speed, acceleration, braking) must reach the server before the move it affects, or the server corrects the client. Send it as soon as it changes and apply it on the server when it arrives. The CMC cover does this: it sends at once on entering or leaving cover or a cover run, and calls On Remote Cover State Applied so the pawn refreshes its movement settings right away. Settings chosen from input must read the CharacterMovement's current acceleration (the last move), which the server knows, not the pending input.
- Components that use RPCs or replicated variables need Component Replicates on the pawn's component. The camera, traversal, equipment, overlay and visual override components have it on in both sample pawns (set on the pawn's component, not the class default): if you build your own pawn, turn it on for them too.
AC_CoverSystem_CMC,AC_DebugToolsand the ragdoll and interaction components (AC_RagdollSystem_Base,AC_InteractionSystem_Baseand their adapters) replicate by default and need nothing. - Make cosmetic reactions run from replicated state so late joiners see them too.