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) and connected_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_server feature (Export → Resources → "Dedicated Server" strips visuals) and run with --headless. Branch with OS.has_feature("dedicated_server") or DisplayServer.get_name() == "headless".

RPCs

  • GDScript: @rpc("any_peer" | "authority", "call_local" | "call_remote", "reliable" | "unreliable" | "unreliable_ordered", channel). Call with rpc(&"method", args) (everyone) or rpc_id(peer, &"method", args). The default @rpc is authority-only, call_remote and reliable.
  • C#: [Rpc(MultiplayerApi.RpcMode.AnyPeer, CallLocal = true, TransferMode = MultiplayerPeer.TransferModeEnum.Reliable)], then Rpc(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 every any_peer RPC on the server: is the sender allowed, is the value sane, is it rate-limited?
  • Use unreliable for frequent state (positions), reliable for events (damage, chat, spawn requests) and unreliable_ordered for streams where old packets are useless. Use separate channels for unrelated reliable streams so they don't block each other.
Installs
11
GitHub Stars
54
First Seen
9 days ago