godot-networking
Installation
SKILL.md
Networking (4.7)
Architecture first
- Server-authoritative. The server (or listen host) owns game state. Clients send inputs and requests, never results ("I picked up item 42", not "my gold is 9999").
- Peer IDs: the server is always
1.multiplayer.get_unique_id(),multiplayer.is_server(),multiplayer.get_peers(). Signals:peer_connected/peer_disconnected(all) andconnected_to_server/connection_failed/server_disconnected(clients). - Transports (all are
MultiplayerPeer, so swapping is trivial):ENetMultiplayerPeer(UDP, desktop and mobile, the default choice),WebSocketMultiplayerPeer(web clients; host needs TLS for https pages),WebRTCMultiplayerPeer(P2P, needs signaling), and Steam through the GodotSteam extension. - Dedicated server: export with the
dedicated_serverfeature (Export → Resources → "Dedicated Server" strips visuals) and run with--headless. Branch withOS.has_feature("dedicated_server")orDisplayServer.get_name() == "headless".
RPCs
- GDScript:
@rpc("any_peer" | "authority", "call_local" | "call_remote", "reliable" | "unreliable" | "unreliable_ordered", channel). Call withrpc(&"method", args)(everyone) orrpc_id(peer, &"method", args). The default@rpcis authority-only, call_remote and reliable. - C#:
[Rpc(MultiplayerApi.RpcMode.AnyPeer, CallLocal = true, TransferMode = MultiplayerPeer.TransferModeEnum.Reliable)], thenRpc(MethodName.Fire, dir)/RpcId(1, MethodName.Fire, dir). - The method must exist with the same RPC config on every peer, at the same node path. Spawn replicated nodes through MultiplayerSpawner so names and paths match.
- Inside an RPC,
multiplayer.get_remote_sender_id()tells you who called. Validate everyany_peerRPC on the server: is the sender allowed, is the value sane, is it rate-limited? - Use
unreliablefor frequent state (positions),reliablefor events (damage, chat, spawn requests) andunreliable_orderedfor streams where old packets are useless. Use separate channels for unrelated reliable streams so they don't block each other.