unity-netcode-design

Provides source-anchored design rules for Netcode for GameObjects 2.x multiplayer code.

2|Updated May 18, 2026
One-click install
npx skills add https://github.com/pcone-mm/NewFPG --skill unity-netcode-design-pcone-mm
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-netcode-design
Source: https://github.com/pcone-mm/NewFPG/tree/main/.agents/skills/unity-skills/skills/netcode-design
Command: npx skills add https://github.com/pcone-mm/NewFPG --skill unity-netcode-design-pcone-mm

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Unity multiplayer code with Netcode for GameObjects often leads to subtle bugs: RPCs with wrong naming, NetworkVariables initialized too late, client-side spawn attempts, and scene sync failures. This Skill provides design rules distilled directly from the Netcode for GameObjects 2.x source code, each citing a concrete file and line, so AI-generated or human-written netcode follows the framework's actual constraints. ## Core Features & Use Cases - Critical Rule Summary: Ten must-know rules covering Spawn/Despawn authority, OnNetworkSpawn ordering, RPC naming constraints, prefab registration, and NetworkVariable type limits. - Topical Reference Docs: Deep dives into lifecycle ordering, ownership and permission matrices, RPC models (universal [Rpc(SendTo.X)] vs legacy ServerRpc/ClientRpc), NetworkVariable/NetworkList constraints, spawning and prefab registration, scene management, and UnityTransport configuration. - Pitfalls Checklist: 30 concrete anti-patterns AI agents commonly introduce, each with a source anchor and a corrected code pattern. - Use Case: Before writing a NetworkBehaviour with health sync and shooting, load this Skill to correctly initialize NetworkVariables at field declaration, gate spawn logic behind IsServer, and route client input through [Rpc(SendTo.Server)]. ## Quick Start Ask the AI to review or write a Unity Netcode NetworkBehaviour script, for example to create a server-authoritative player health system with RPC-based shooting.

Frequently Asked Questions about unity-netcode-design

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I correctly spawn a NetworkObject in Netcode for GameObjects?

Spawn must be called on the Server or Host only; client-side calls fail. Register the prefab in NetworkConfig.Prefabs or a NetworkPrefabsList, then call Instantiate plus NetworkObject.Spawn(), or use NetworkSpawnManager.InstantiateAndSpawn for a one-shot path.

What is the difference between [Rpc(SendTo.Server)] and [ServerRpc]?

The universal [Rpc(SendTo.X)] attribute is the recommended 2.x model with no method-name constraint and 11 SendTo targets. Legacy [ServerRpc] and [ClientRpc] still work but ILPP requires method names ending in ServerRpc or ClientRpc.

Why is my NetworkVariable not syncing in Unity Netcode?

Common causes include constructing the NetworkVariable inside OnNetworkSpawn instead of at field declaration, using unsupported types like string or List<T>, or writing from a client when write permission defaults to Server. Initialize at the field and use FixedString or NetworkList.

Does Netcode for GameObjects 2.x support distributed authority?

Yes, setting NetworkConfig.NetworkTopology to DistributedAuthority removes the dedicated server role so each NetworkObject has its own authority. Use SendTo.Authority instead of SendTo.Server, though ClientServer remains the recommended default for typical games.

Why does OnNetworkSpawn run before Start in Unity Netcode?

Netcode invokes OnNetworkSpawn after Awake and OnEnable but before the first frame's Start, so network state like IsOwner and IsSpawned is valid there. Initialization depending on network state belongs in OnNetworkSpawn, not Awake or Start.

When should I not use NetworkTransform alternatives like manual RPC position sync?

Per-frame position sync via reliable RPCs wastes bandwidth and accumulates latency. Use NetworkTransform for transform replication, or if hand-rolling, use RpcDelivery.Unreliable with NetworkVariable UpdateTraits throttling.