Skip to content

77 game-dev skills for AI coding agents — Godot, Unity, Unreal, Phaser, PixiJS, three.js, Bevy, pygame, LÖVE, Roblox. Portable SKILL.md Agent Skills (the format Anthropic launched as Claude Skills), with a router that loads the right skill for your engine and task. Runs in Claude Code, Cursor, Kiro, Codex, Copilot, Gemini CLI and more.

fix(godot): make server-to-owner RPCs work on client-owned nodes, fix auth handshake and sync modes

Kiro Crew5698c1ecf7a1
diff --git a/skills/godot/godot-multiplayer/SKILL.md b/skills/godot/godot-multiplayer/SKILL.md
index bf461e0..5f378ec 100644
--- a/skills/godot/godot-multiplayer/SKILL.md
+++ b/skills/godot/godot-multiplayer/SKILL.md
@@ -35,7 +35,7 @@ work (low-level `PacketPeer`); HTTP requests. For save/persistence → `save-sys
`rpc_id(peer_id)` (one peer). Inside, `multiplayer.get_remote_sender_id()` tells you who
sent it.
4. **Keep RPC signatures identical** on every peer that runs the script — Godot checksums
- all `@rpc` methods in a script; mismatches break silently.
+ all `@rpc` methods in a script; a mismatch prints errors that can name an unrelated RPC.
5. **Assign authority** per node with `set_multiplayer_authority(id)`; gate input/RPCs by
`is_multiplayer_authority()`.
6. **Replicate state** with `MultiplayerSpawner` (auto-instances scenes on clients) and
@@ -70,6 +70,10 @@ func leave() -> void:
### 2. RPCs: client sends input to the server (any_peer, call_local)
+This script sits on a player avatar whose authority is the owning client (Pattern 3), so
+the server is *not* the node's authority. A server→clients RPC on such a node must be
+`"any_peer"` and check that the sender is the server.
+
```gdscript
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("fire") and is_multiplayer_authority():
@@ -78,13 +82,19 @@ func _unhandled_input(event: InputEvent) -> void:
# Clients may call this; it runs on the server (and locally if server is a player).
@rpc("any_peer", "call_local", "reliable")
func request_fire() -> void:
+ if not multiplayer.is_server(): # ignore copies relayed to other clients
+ return
var sender := multiplayer.get_remote_sender_id()
if not _can_fire(sender): # server-side validation
return
spawn_projectile.rpc(sender) # tell everyone to spawn it
-@rpc("authority", "call_local", "reliable")
+# "authority" here would make clients reject the server's call (the client is the
+# authority), so accept any peer and keep only calls that come from the server.
+@rpc("any_peer", "call_local", "reliable")
func spawn_projectile(owner_id: int) -> void:
+ if multiplayer.get_remote_sender_id() != 1:
+ return
_do_spawn(owner_id)
```
@@ -113,7 +123,9 @@ func _physics_process(delta: float) -> void:
@onready var sync: MultiplayerSynchronizer = $MultiplayerSynchronizer
func _ready() -> void:
- # Only replicate this node to a specific peer (e.g. private info).
+ # Only replicate this node to a specific peer (e.g. private info). Per-peer visibility
+ # matters only once public_visibility is off; by default every peer receives it.
+ sync.public_visibility = false
sync.set_visibility_for(target_peer_id, true)
```
@@ -125,6 +137,10 @@ func _ready() -> void:
the set of RPCs and their annotations are.
- **Default `@rpc` is `"authority"`.** Clients calling it are ignored unless you set
`"any_peer"`. Use `"call_local"` so the host (also a player) runs it too.
+- **`RPC 'x' is not allowed on node ... from: 1. Mode is "authority"`** → the server called
+ an `"authority"` RPC on a node a client owns. "Authority" means the node's authority, not
+ the server. Use `"any_peer"` plus a `get_remote_sender_id() == 1` check, or move
+ server-driven RPCs to a server-owned node (e.g. a game manager).
- **NodePaths must match across peers.** RPC routing uses the node's path/name; spawn nodes
with identical names on all peers (use `MultiplayerSpawner` or `add_child(node, true)` for
readable, deterministic names).
diff --git a/skills/godot/godot-multiplayer/references/replication-and-rpc.md b/skills/godot/godot-multiplayer/references/replication-and-rpc.md
index 41e7aa3..a09acff 100644
--- a/skills/godot/godot-multiplayer/references/replication-and-rpc.md
+++ b/skills/godot/godot-multiplayer/references/replication-and-rpc.md
@@ -17,8 +17,9 @@ Defaults — `@rpc` is equivalent to `@rpc("authority", "call_remote", "reliable
- **transfer_mode**: `"reliable"` (acknowledged, ordered, slower), `"unreliable"`
(fire-and-forget, may drop/reorder — good for frequent position updates), or
`"unreliable_ordered"` (drops late packets to preserve order).
-- **transfer_channel**: integer channel index; the first three args can be in any order
- but the channel must be last. Use separate channels to keep unrelated streams from
+- **transfer_channel**: integer channel index; the first three args can be in any order,
+ but the channel must be the 4th argument, so all three must be given before it. Use
+ separate channels to keep unrelated streams from
blocking each other.
Call forms (on a `Callable` for the method):
@@ -35,10 +36,11 @@ Auto-instantiates scenes on remote peers when the authority spawns them.
1. Add a `MultiplayerSpawner` node; set its **Spawn Path** to the parent that will hold
spawned instances.
-2. Add the scenes it may spawn to its **Auto Spawn List** (or use a custom spawn function
- via `spawn_function`).
-3. On the authority, call `spawner.spawn(data)` or simply `add_child()` a scene under the
- spawn path — the spawner replicates it to clients with a matching name.
+2. Add the scenes it may spawn to its **Auto Spawn List** (`add_spawnable_scene()` in code).
+3. On the authority, `add_child()` one of those scenes under the spawn path — the spawner
+ replicates it to clients with a matching name. For custom setup, assign a
+ `spawn_function` (it receives your `data` and returns the node) and call
+ `spawner.spawn(data)`; `spawn()` errors without a `spawn_function`.
```gdscript
@onready var spawner: MultiplayerSpawner = $MultiplayerSpawner
@@ -55,10 +57,16 @@ Replicates chosen properties from the authority to other peers each network tick
- Add it as a child of the node to sync. In the **Replication** dock, add property paths
(e.g. `:position`, `:velocity`, `Sprite2D:modulate`).
-- Per property: **Spawn** (sent once at spawn) and **Sync** (sent continuously) flags, plus
- a replication interval.
-- `replication_interval` / `delta_interval` tune bandwidth.
-- Visibility filtering for per-peer data:
+- Per property: **Spawn** (sent once when the node is spawned) and a **Replicate** mode:
+ *Always* (unreliable, every `replication_interval`), *On Change* (reliable, checked every
+ `delta_interval` and sent only when the value changed) or *Never*. In code use
+ `SceneReplicationConfig.property_set_replication_mode()`; `property_set_sync` and
+ `property_set_watch` are deprecated.
+- `replication_interval` / `delta_interval` (on the synchronizer) tune bandwidth.
+- Visibility filtering for per-peer data. A peer receives the node only if every filter
+ returns `true` **and** it is visible to that peer — `public_visibility` (default `true`) or
+ `set_visibility_for(peer, true)`. So `set_visibility_for` alone does nothing until
+ `public_visibility` is off:
```gdscript
sync.set_visibility_for(peer_id, true)
sync.add_visibility_filter(func(peer): return _can_see(peer))
@@ -73,21 +81,30 @@ per-node authority so each player's synchronizer pushes that player's state.
Protect RPCs from unauthenticated peers using the built-in handshake:
```gdscript
-# Server, after assigning the peer:
-multiplayer.auth_timeout = 3.0
-multiplayer.auth_callback = func(peer_id: int, data: PackedByteArray):
- var info := JSON.parse_string(data.get_string_from_utf8())
- if _valid(info):
- multiplayer.complete_auth(peer_id)
-
-# Client:
-multiplayer.peer_authenticating.connect(func(peer_id: int):
- var payload := JSON.stringify({"token": _token}).to_utf8_buffer()
- multiplayer.send_auth(1, payload)
-)
+# Both sides set auth_callback BEFORE assigning multiplayer_peer.
+@onready var sm := multiplayer as SceneMultiplayer # auth API lives on SceneMultiplayer
+
+func setup_server_auth() -> void:
+ sm.auth_timeout = 3.0
+ sm.auth_callback = func(peer_id: int, data: PackedByteArray) -> void:
+ var info: Variant = JSON.parse_string(data.get_string_from_utf8())
+ if info is Dictionary and _valid(info):
+ sm.complete_auth(peer_id)
+
+func setup_client_auth() -> void:
+ # The client needs an auth_callback too, or it skips the handshake entirely.
+ sm.auth_callback = func(_peer_id: int, _data: PackedByteArray) -> void:
+ pass # read the server's reply here, if any
+ sm.peer_authenticating.connect(func(peer_id: int) -> void:
+ var payload := JSON.stringify({"token": _token}).to_utf8_buffer()
+ sm.send_auth(peer_id, payload)
+ sm.complete_auth(peer_id) # the client must complete its side too
+ )
```
`connected_to_server` / `peer_connected` only fire once both sides call `complete_auth()`.
+If the client never calls it, the handshake times out and `peer_authentication_failed`
+fires; if the client has no `auth_callback`, the server waits for data that never comes.
## Transfer mode guidance