Godot multiplayer (network programmer)
Target: Godot 4.7.2, SceneMultiplayer over ENet and WebSocket.
Expert level here means the networked game is proven with several processes, under injected latency,
before anyone plays it: authority is a written decision per object, every client message is a
request the server checks, and replication cost is measured in KiB/s. This skill builds the
replication in code, runs a server and 2 to 3 clients headless on localhost (plus a browser client),
and passes only on numbers from those runs. If a sibling skill named here is missing from your
available skills, load it with skill_get (Scenario MCP) or ask the user to install it
(https://github.com/scenario-labs/skills#install); unattended, proceed from tool schemas and flag
the gap.
REQUIRED BACKGROUND: scenario-godot-expert (channels, gd_run, review loop, 4.7 traps).
Status (2026-10-02): 16 live tests (up to 3 clients, ENet, WebSocket, exported server, headless
Chrome) and 18 offline tests pass. Evidence: tests/live_evidence/godot-multiplayer/.
Stance (the expert delta)
- Decide authority per object before writing code. Someone must own each object's data
(AndrooDev, jff9oxO8v1s [00:04:01]). Client authority over the body is fine for casual co-op;
competitive or cheat-prone games keep the body on the server and give clients their input only
(Tamas Galffy, iP_xdJ0peFo [00:03:46, 00:06:47]; BatteryAcidDev, GqHTNmRspjU [00:00:33]).
Deciding condition: cost of cheating against cost of input lag. Measured at 250 ms RTT: server
authority shows your own move after 294 to 310 ms, client authority after 11 to 22 ms, and a
client-authority cheater's 50 m jump stuck.
- Set authority from the node name in
_enter_tree. Name each player node with its peer id;
_enter_tree calls set_multiplayer_authority(name.to_int()) so it holds before _ready
(Travis Hunter, tK2ACXUGcrY [00:46:16]). Do not read a spawn-synced property there: on every
client copy measured, peer_id was still 0 in _enter_tree.
- Every
any_peerRPC is a request. Readmultiplayer.get_remote_sender_id()first (it is 0
after an await, measured), check that the sender owns the target and that the values are
possible, then act. A forged teleport for another player and a 30 m jump were both rejected in
the live test.
- The RPC checksum compares method names only, whatever the docs say. The high-level docs say
it covers every @rpc declaration and skips arguments; two live runs in 4.7.2 (M2, round 1 and
round 2) disagree. A name missing on one side logs "The rpc node checksum failed" on both sides
and RPCs are matched by sorted index: the client called b and the server ran a. A different
mode only fails per call ("not allowed"), a different argument count fails per call ("expected 2
argument(s)"), different call_local or transfer mode passes silently. Keep server and client on
one script per node path (one codebase: Davide Di Staso, nyKBuM9Y_-Q).
- Test with latency and three players. Localhost hides every latency bug; two players hide what
a bystander sees (Galffy, iP_xdJ0peFo [00:09:58, 00:42:31]). gd_net.UdpLagProxy adds delay,
jitter and loss on localhost without root.
- Replication cost is a design input. ALWAYS sends every network frame whether or not the value
changed; ON_CHANGE is reliable and costs more than ALWAYS while values move (measured: 72.6
against 100 KiB/s for 50 moving props). A headless server is uncapped: 145 fps here, 2.2 to 2.4
times the bandwidth of 60 fps. Cap it (--max-fps, Engine.max_fps) or set
replication_interval. Cut by visibility (Di Staso [00:14:29]).
- Know which connection event fires where. On a joining client,
peer_connectedfires once per
existing peer, server id 1 included; connected_to_server fires on clients only, so send client
info there, not from peer_connected (docs delta 7; FinePointCGI e0JLO_5UgQo [00:22:50]). After
the server leaves, get_unique_id() reads 0: skip id 0 in registries and spawn loops
(pA9RGn87Uag [00:47:31]). All measured (M14).
- The server stops speed hacks, not wall hacks. Server authority blocks impossible moves and
infinite health; it does not stop wall hacks or aimbots, because every client still receives
everyone's position. Interest management (synchronizer visibility, server line-of-sight checks)
limits the leak (MfjEB1cowsE [00:18:55]; iP_xdJ0peFo [00:53:28]).
- The dedicated server is the same project exported in "dedicated server" mode. That mode adds
the dedicated_server feature, which forces headless display and dummy audio even without
--headless (measured on the exported macOS binary), and Strip Visuals removed the 3.1 MB
texture from the server pack (BatteryAcidDev, jgJuX04cq7k [00:04:47]).
Establish first
Genre and player count; who may cheat (competitive, co-op, friends only); platforms (browser means
WebSocket or WebRTC, no ENet); topology (dedicated server, listen server, relay or P2P); a backend
already chosen (Steam, Nakama, Colyseus, own server); hosting budget (cloud costs money: ask before
any deployment); tick and target RTT (default 60 Hz server, play tested at 100 and 250 ms).
Defaults: one project, server authority with input-only clients for anything competitive, ENet for
desktop and mobile, WebSocket behind TLS (wss://) for the web.
Workflow
- Network design note. Per object: owner, what replicates (synchronizer property and mode),
what is an event (RPC with mode, transfer and channel), what a client may request. Streams of
unreliable_ordered updates get their own transfer channel, channel last in @rpc (docs deltas 4,
5); idle players send nothing below a velocity threshold (pA9RGn87Uag [00:42:16]). GATE: no
object without an owner; no client-owned health, score or inventory unless the brief accepts
cheating.
- Build the replication in code.
gd_net.install_netkit(P), then