Network sync: authoritative server (Source-style)

Provides server-authoritative multiplayer: a fixed server tick, user commands, client prediction and reconciliation, interpolation of remote entities, lag-compensated hits and delta snapshots.

Source: module-kits:kits/net_authoritative/usage/en.mdView Markdown source

Also read offline — CLI: grip-forge docs net-authoritativeMCP tool: gripforge_docs { "topic": "net-authoritative" }

Network sync: authoritative server (Source-style) (net.authoritative) #

What it is for #

Provides server-authoritative multiplayer: a fixed server tick, user commands, client prediction and reconciliation, interpolation of remote entities, lag-compensated hits and delta snapshots.

It needs net.transport, input.actions, game.engine; installing it brings them in.

Turn it on #

Install the kit in a project, then change a setting (the values shown are its defaults):

gripforge_gamekit_install   { project_id: "gkp_…", id: "net.authoritative" }
gripforge_gamekit_configure { project_id: "gkp_…", id: "net.authoritative",
                              config: { "tickHz": 30, "snapshotHz": 20 } }

First example #

<!-- test: kits/net_authoritative/tests/net_authoritative.rs::the_session_is_an_authoritative_client_that_connects --> This is the body of the passing test the_session_is_an_authoritative_client_that_connects; the helper functions it calls are defined at the top of the same test file.

#[test]
fn the_session_is_an_authoritative_client_that_connects() {
    let mut s = online(json!({}));
    let sessions = call(&mut s, "probe.core", "sessions", json!([]));
    assert_eq!(sessions[0]["config"]["model"], "authoritative");
    assert_eq!(sessions[0]["config"]["role"], "client");
    assert_eq!(commands(&mut s)[0]["c"], "connect");
    assert_eq!(
        call(&mut s, "net.prediction", "session", json!([])),
        json!(1)
    );
    assert_eq!(
        call(&mut s, "net.lag_compensation", "client", json!([])),
        json!(1)
    );
    // The fire action is registered for the player to rebind.
    assert!(s.host.state.get("net.hp").is_some());
}

Settings and defaults #

Descriptions come from the kit manifest and stay in English.

SettingTypeDefaultRange or valuesMeaning
tickHzinteger305–128Server simulation rate (Source: 64–128 for shooters).
snapshotHzinteger201–128Snapshots per second (≤ tickHz).
cmdRedundancyinteger31–8Each command packet repeats the last N commands (loss tolerance).
interpolationMsinteger1000–1000Remote entities are drawn this far in the past (≥ 2 snapshot intervals).
interpolationBufferinteger322–256Client: snapshots kept for interpolation.
extrapolateMsinteger2500–1000Extrapolate at most this long when snapshots are late.
maxUnlagMsinteger10000–2000Lag compensation window (sv_maxunlag).
unlagMarginTicksinteger20–64Lag compensation: a shot may rewind this many ticks beyond the measured latency.
lagSmoothingnumber0.20.01–1Weight of a new sample in the server-side latency estimate of a player (EWMA).
maxCmdsPerTick0Commands consumed per player per tick (catch-up after loss, caps speed hacks).
repeatLastCmdMs-1Server: when a player's command queue runs dry, its last movement input (axes, view, sprint — never fire, jump or other actions)…
inputBufferTicks-1Server command queue depth (ticks) the client aims at when timeDilation is on, so jitter does not starve the server (announced by…
timeDilationnumber00–0.25Client clock dilation (fraction, both ways) that keeps the server queue at inputBufferTicks: faster when the server runs dry,…
resimCatchupinteger41–16Body prediction, engines without a synchronous physics step (Godot): net steps per physics frame while a resimulation catches up…
starvedMsinteger2500–10000Client: no snapshot for this long while connected → event starved (then fed with the gap when they resume); counted in…
maxQueuedCmdsinteger644–256Queued commands per player; the oldest are dropped beyond.
maxPendingCmdsinteger2568–4096Client: unacknowledged predicted commands kept (replayed on correction).
maxPitchnumber1.50.1–1.5707Client: view pitch bound (rad) of the commands.
errorSmoothingMsinteger1000–1000Prediction errors are blended out over this time.
snapshotHistoryinteger648–256Snapshots kept per client as delta baselines (server and client; announced in the welcome).
relevanceRadiusnumber00–100000Only entities within this distance are sent (0 = everything).
hitRadiusnumber0.50.05–10Player hit sphere radius (m).
hitHeightnumber10–10Hit sphere centre above the feet (m).
eyeHeightnumber1.60–10Shot origin above the feet (m).
fireRangenumber2001–10000Hitscan range (m).
fireRateHznumber100.1–60Shots per second (enforced by the server).
fireImpulsenumber00–1000000physics shared: impulse (N·s) a shot gives the dynamic body it hits (0 = shots ignore bodies).
damagenumber250–1000Damage per hit.
maxHpnumber1001–100000Player health.
respawnMsinteger30000–600000Respawn delay after death.
spawnRadiusnumber50–10000Players spawn on a ring of this radius (m).
physicsstring"none"none, native, sharedBodies: none; native = the engine physics simulates (owner / dedicated server), the core replicates states, sleep and…
playerRadiusnumber0.40.05–10physics native / shared: radius of the player capsule (m, announced to the engines).
playerHalfHeightnumber0.50–10physics native / shared: half height of the capsule cylinder (m; 0 = a sphere).
predictstring"auto"auto, none, movement, bodiesClient prediction: none (everything interpolated), movement (the local player, reconciled on each snapshot), bodies (also the…
playerTolerancenumber0.010–10Prediction: player position error (m) below which the prediction is kept.
playerVelTolerancenumber0.10–100Prediction: player velocity error (m/s) below which the prediction is kept.
playerResimnumber0.50–100Prediction: position error (m) below which a soft correction (shift + blend) is enough; above, reset and replay (≥…
playerVelResimnumber30–1000Prediction: the same for the velocity error (m/s, ≥ playerVelTolerance).
bodyTolerancenumber0.020–10Body prediction: position error (m) below which a predicted body is kept.
bodyRotTolerancenumber0.050–3.2Body prediction: rotation error (rad) below which it is kept.
bodyVelTolerancenumber0.250–100Body prediction: velocity error (m/s) below which it is kept.
bodyResimnumber0.30–100Body prediction: position error (m) above which the bodies are restored and resimulated (≥ bodyTolerance).
bodyRotResimnumber0.350–3.2Body prediction: the same for rotation (rad, ≥ bodyRotTolerance).
bodyVelResimnumber1.50–1000Body prediction: the same for velocity (m/s, ≥ bodyVelTolerance).
predictRadiusnumber60–1000Body prediction: bodies within this distance of the local player are predicted.
predictHysteresisnumber1.251–4Body prediction: a predicted body stays predicted up to predictRadius × this.
maxPredictedBodiesinteger80–64Body prediction: bodies predicted at once (nearest first).
maxResimTicksinteger300–256Body prediction: longer resimulations are skipped (restore only).
bodyPlanTimeoutMsinteger50050–10000Body prediction: a step plan the host does not finish within this delay is dropped.
blendThresholdnumber0.020–100Drawn discontinuities above this (m) are blended out.
blendSpeednumber30.01–1000A blend moves the drawn pose by at most this speed (m/s) on top of its motion.
snapDistancenumber20–10000Drawn discontinuities and player corrections beyond this (m) snap instead of blending.
resimAlwaysbooleanfalseBenchmark: resimulate the bodies on every snapshot.
remotePlayersstring"predicted"none, drawn, predictedBody prediction: the OTHER players' capsules in the predicted world (others of body_step).
remoteExtrapolationMsinteger3500–1000Body prediction, remotePlayers predicted: a remote capsule is extrapolated at most this far ahead of its latest snapshot, by at…
remoteConfidencenumber0.90–1Body prediction, remotePlayers predicted: share of the recent extrapolations of a remote player (checked against the snapshots)…
remoteTolerancenumber0.250.01–10Body prediction, remotePlayers predicted: an extrapolation that lands within this distance (m) of the snapshot counts as right.
remoteLatchRadiusnumber20–100Body prediction, remotePlayers predicted: while a remote capsule is within this distance (m) of a predicted body, whether it is…
predictHistoryTicksinteger51264–8192Client: predicted player states kept per command (reconciliation, body prediction).
bodyHistoryTicksinteger25616–8192Body prediction: body states kept per tick (client) and command numbers per tick (server).
tickEventsbooleanfalseServer: emit a tick event every tick.
bodyStepEventsbooleanfalseServer, physics native: emit body_step every tick (always on with predict bodies).
statsFullBytesbooleanfalseServer: also weigh each snapshot as full states (stats fullBytes: the delta savings; costly).
moveobject{"speed": 6, "sprint": 1.6, "accel": 60, "fri…Player movement, identical on the server and in the client prediction (announced in the welcome; a partial object keeps the other…

Services, events, variables #

  • Service net.sync: The project replication model (one per project: the net.* sync kits conflict with each other).
  • Service net.prediction: Predicted local player, reconciled on each snapshot; remote entities interpolated.
  • Service net.lag_compensation: Server-side rewind of the other players to the shooter's render time.
  • Events emitted:
    • net.hit (by, target, damage, kill) — A lag-compensated hit confirmed by the server.
    • net.correction (error, snapped) — The server corrected the local prediction.
    • net.starved (ms) — No snapshot for starvedMs while connected (a stalled downlink: remote entities extrapolate, the prediction lead is frozen).
    • net.fed (ms) — Snapshots resumed after a starved gap of ms.
    • net.resim (ms, steps) — Web runtime, predict bodies: the predicted bodies were restored and resimulated (cost in ms, physics steps replayed).
  • Variables:
    • net.status (string) — Network status
    • net.rtt (number) — Ping (ms)
    • net.peers (number) — Players online
    • net.hp (number) — Health
  • Input actions: net_fire

Hooks and modding #

This kit declares no hook and no collection to mod.

Engines #

Declared targets: web, godot, unity, unreal. gripforge kit api net.authoritative lists the exact settings and services of your version.

Versions #

Kit version 1.2.0.