unity-netcode-design

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

Updated Aug 31, 2026
One-click install
npx skills add https://github.com/pikachu0310/codex-agent-ops-public --skill unity-netcode-design-pikachu0310
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-netcode-design
Source: https://github.com/pikachu0310/codex-agent-ops-public/tree/main/.agents/skills/unity-skills/skills/netcode-design
Command: npx skills add https://github.com/pikachu0310/codex-agent-ops-public --skill unity-netcode-design-pikachu0310

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing Unity multiplayer code with Netcode for GameObjects is error-prone: AI agents and developers frequently misuse RPC attributes, spawn objects on clients, misread lifecycle ordering, or violate NetworkVariable type constraints. This Skill distills verifiable design rules from the actual Netcode for GameObjects 2.x source code, each with a file/line citation, so generated or reviewed netcode is correct by construction. ## 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. - Routed Sub-documents: Eight focused references covering lifecycle, ownership/authority, RPC semantics, NetworkVariable/NetworkList, spawning, scene management, transport configuration, and a 30-item pitfalls checklist. - Anti-pattern vs Correct Pattern Pairs: Every rule includes wrong/correct C# code examples grounded in source anchors. - Use Case: Before writing a NetworkBehaviour with RPCs and NetworkVariables, load this module to verify SendTo semantics, permission matrices, and ILPP serialization constraints, then scan the pitfalls checklist during code review. ## Quick Start Ask the AI to review your NetworkBehaviour script using the unity-netcode-design rules and flag any violations of RPC, spawning, or NetworkVariable constraints.

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 NetworkObjects in Netcode for GameObjects?

Spawn must be called on the Server or Host only; client-side calls fail. Clients request spawning via a [Rpc(SendTo.Server)], and the server runs Instantiate plus NetworkObject.Spawn(), or uses NetworkSpawnManager.InstantiateAndSpawn for a one-shot path.

What is the difference between [Rpc(SendTo.X)] and legacy [ServerRpc]/[ClientRpc]?

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

Why does my NetworkVariable not sync when created in OnNetworkSpawn?

NetworkVariables must be initialized at field declaration time so ILPP can register them at compile time. Creating them inside OnNetworkSpawn is too late; use OnNetworkSpawn only for subscriptions and initial values.

Does Netcode for GameObjects support NetworkVariable<string> or NetworkVariable<List<T>>?

No. NetworkVariable<T> requires T to be unmanaged or implement INetworkSerializable. Use FixedString32Bytes for strings and NetworkList<T> (where T is unmanaged and IEquatable) for replicated collections.

When should I use OnNetworkSpawn instead of Awake or Start?

OnNetworkSpawn runs after Awake/OnEnable but before Start, and it is the first point where IsSpawned, IsOwner, and IsServer are valid. Any initialization depending on network state belongs there, not in Awake or Start.

Which Netcode for GameObjects version do these rules target?

The rules target com.unity.netcode.gameobjects 2.x, validated against 2.11.0 with Unity 6000.0+. APIs like SendTo.Authority, RpcInvokePermission, and the universal [Rpc] attribute do not exist in 1.x.