unity-networking — Claude Code skill for Unity multiplayer
The unity-networking Claude Code skill supports multiplayer networking work in Unity. It activates for framework setup, RPCs, synchronized state, lobbies, and server-authoritative designs.
MIT 103 installs ★ 66 updated 2026-06-18
npx skills add JosiahSiegel/claude-plugin-marketplace --skill unity-networking -a claude-codeWhat unity-networking does
The skill compares Unity networking options, including NGO, Mirror, Photon PUN, Photon Fusion, and Fish-Net. For NGO, it covers initial setup, RPC patterns, and synchronized values with NetworkVariable.
It also describes lobby and matchmaking flows, Relay, dedicated servers, prediction, and lag compensation. NGO setup uses the com.unity.netcode.gameobjects package; a scene needs a NetworkManager, and networked objects use NetworkObject. The server should validate client actions.
What it helps with
- compare networking frameworks for a Unity game
- set up RPC calls and synchronized state
- outline a lobby and matchmaking flow
- design server-side validation for player actions
Example prompts for the agent
- Compare NGO and Mirror for a Unity multiplayer game.
- Show how to use RPCs and
NetworkVariablewith NGO. - Outline a lobby flow using Relay and server-side action checks.
How to install unity-networking
1Skills CLI (Vercel)
npx skills add JosiahSiegel/claude-plugin-marketplace --skill unity-networking -a claude-code2Manually: put the files in place
~/.claude/skills/unity-networking/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/unity-networking/
1Skills CLI (Vercel)
npx skills add JosiahSiegel/claude-plugin-marketplace --skill unity-networking -a codex2Manually: put the files in place
.agents/skills/unity-networking/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add JosiahSiegel/claude-plugin-marketplace --skill unity-networking -a cursor2Manually: put the files in place
.cursor/skills/unity-networking/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install JosiahSiegel/claude-plugin-marketplace plugins/unity-master/skills/unity-networking2Manually: put the files in place
.github/skills/unity-networking/SKILL.md1Skills CLI (Vercel)
npx skills add JosiahSiegel/claude-plugin-marketplace --skill unity-networking -a gemini-cli2Platform CLI
gemini skills install https://github.com/JosiahSiegel/claude-plugin-marketplace --path plugins/unity-master/skills/unity-networkingManually: put the files in place
.devin/skills/unity-networking/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add JosiahSiegel/claude-plugin-marketplace --skill unity-networking -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about unity-networking
How do I install unity-networking in Claude Code?
Run npx skills add JosiahSiegel/claude-plugin-marketplace --skill unity-networking -a claude-code. The skill file is located at ~/.claude/skills/unity-networking/SKILL.md.
What does unity-networking do?
It helps with Unity multiplayer networking, from framework comparisons and NGO setup to RPCs, lobby flows, and authority design.
Which package does NGO setup use?
The setup uses com.unity.netcode.gameobjects. It also adds NetworkManager to a scene and marks networked objects with NetworkObject.
Source text
SKILL.md · MIT
---
name: unity-networking
description: |
Unity multiplayer networking with NGO, Mirror, Photon, and Fish-Net.
PROACTIVELY activate for: (1) building Unity multiplayer games, (2) Netcode for GameObjects (NGO) setup and patterns, (3) Mirror networking, (4) Photon PUN and Photon Fusion, (5) Fish-Net networking, (6) RPCs (ClientRpc, ServerRpc), (7) NetworkVariable and network synchronization, (8) lobby and matchmaking systems, (9) dedicated server hosting and Relay, (10) server-authoritative architecture, (11) lag compensation and prediction.
Provides: networking-stack comparison, NGO templates, RPC patterns, NetworkVariable usage, lobby/matchmaking setup, and authoritative-server design.
---
# Unity Networking and Multiplayer
## Overview
Reference for implementing multiplayer systems and backend services in Unity. Covers the major networking frameworks, authority models, common multiplayer patterns, and Unity Gaming Services integration.
## Networking Framework Comparison
| Framework | Type | Best For | License |
|-----------|------|----------|---------|
| Netcode for GameObjects (NGO) | Client-hosted / Dedicated | Unity-native projects, UGS integration | Free (Unity) |
| Mirror | Client-hosted / Dedicated | Open-source alternative, mature ecosystem | MIT |
| Photon PUN 2 | Cloud-hosted | Quick prototyping, room-based games | Free tier + paid |
| Photon Fusion 2 | Cloud/Self-hosted | Competitive games, tick-based simulation | Free tier + paid |
| Fish-Net | Client-hosted / Dedicated | Performance-critical, Mirror alternative | MIT |
## Netcode for GameObjects (NGO)
### Setup
1. Install via Package Manager: `com.unity.netcode.gameobjects`
2. Add `NetworkManager` to a scene GameObject
3. Select transport (Unity Transport is default)
4. Mark networked prefabs with `NetworkObject` component
5. Register prefabs in NetworkManager's prefab list
### Core Components
| Component | Purpose |
|-----------|---------|
| `NetworkManager` | Manages connections, spawning, scene management |
| `NetworkObject` | Required on all networked GameObjects |
| `NetworkBehaviour` | Base class for networked scripts (replaces MonoBehaviour) |
| `NetworkVariable<T>` | Synchronized variable with ownership/permissions |
| `NetworkTransform` | Automatic position/rotation sync |
| `NetworkAnimator` | Automatic Animator parameter sync |
### RPCs (Remote Procedure Calls)
```csharp
public class PlayerCombat : NetworkBehaviour
{
NetworkVariable<int> _health = new(100,
NetworkVariableReadPermission.Everyone,
NetworkVariableWritePermission.Server);
[ServerRpc]
void AttackServerRpc(ulong targetId)
{
// Runs on server - validate and apply damage
if (!IsServer) return;
var target = NetworkManager.SpawnManager.SpawnedObjects[targetId];
target.GetComponent<PlayerCombat>().TakeDamage(10);
}
[ClientRpc]
void PlayHitEffectClientRpc(Vector3 position)
{
// Runs on all clients - visual feedback only
Instantiate(hitVFX, position, Quaternion.identity);
}
void TakeDamage(int amount)
{
_health.Value -= amount;
PlayHitEffectClientRpc(transform.position);
}
}
```
| RPC Type | Direction | Use For |
|----------|-----------|---------|
| `[ServerRpc]` | Client -> Server | Player actions, requests |
| `[ClientRpc]` | Server -> All Clients | VFX, sound, UI updates |
| `[ClientRpc(SendTo.Owner)]` | Server -> Owner Client | Owner-specific feedback |
### NetworkVariable Permissions
```csharp
// Server-writable (default) - authoritative state
NetworkVariable<int> score = new(0, writePerm: NetworkVariableWritePermission.Server);
// Owner-writable - client-authoritative (use sparingly)
NetworkVariable<Vector3> cursorPos = new(writePerm: NetworkVariableWritePermission.Owner);
```
Use `OnValueChanged` callback for UI reactions:
```csharp
_health.OnValueChanged += (oldVal, newVal) => healthBar.value = newVal;
```
## Authority Models
| Model | Description | When to Use |
|-------|-------------|-------------|
| Server-Authoritative | Server validates all actions, clients are thin | Competitive, anti-cheat critical |
| Client-Authoritative | Clients own their state, server relays | Cooperative, trust-based |
| Client Prediction + Server Reconciliation | Client predicts locally, server corrects | FPS, fast-paced action |
| Relay / Listen Server | One player hosts, others connect via relay | Casual, small lobbies |
### Server-Authoritative Flow
```text
Client: Press "Attack" -> Send ServerRpc(targetId)
Server: Validate range/cooldown -> Apply damage -> Update NetworkVariable
Server: Send ClientRpc for VFX
All Clients: Play hit effect
```
Never trust client data. Validate positions, cooldowns, ammunition, and line-of-sight on the server.
## Common Multiplayer Patterns
### Lobby System
```text
1. Player authenticates (UGS Auth / custom)
2. Player creates or joins lobby (UGS Lobby / custom)
3. Lobby fills -> host starts game
4. Relay allocation for NAT traversal (UGS Relay)
5. All players connect to relay
6. NetworkManager starts host/client
```
### Spawn and Despawn
```csharp
// Server-side spawning
var instance = Instantiate(prefab, spawnPoint, Quaternion.identity);
instance.GetComponent<NetworkObject>().SpawnWithOwnership(clientId);
// Server-side despawning
networkObject.Despawn(); // Removes from all clients
```
### Scene Management
Use `NetworkManager.SceneManager.LoadScene("GameScene", LoadSceneMode.Single)` for synchronized scene loading. Only the server/host should call this.
## REST API and WebSocket Integration
### REST API (UnityWebRequest)
```csharp
async Awaitable<T> GetAsync<T>(string url)
{
using var request = UnityWebRequest.Get(url);
request.SetRequestHeader("Authorization", $"Bearer {token}");
await request.SendWebRequest();
if (request.result != UnityWebRequest.Result.Success)
throw new Exception(request.error);
return JsonUtility.FromJson<T>(request.downloadHandler.text);
}
```
Use `JsonUtility` for simple types or Newtonsoft.Json (`com.unity.nuget.newtonsoft-json`) for complex serialization. Always use `using` with UnityWebRequest to prevent memory leaks.
### WebSocket (NativeWebSocket / WebSocketSharp)
For real-time non-game communication (chat, notifications), use a WebSocket library. NativeWebSocket works across platforms including WebGL.
## Unity Gaming Services (UGS)
| Service | Package | Purpose |
|---------|---------|---------|
| Authentication | `com.unity.services.authentication` | Anonymous/platform sign-in |
| Lobby | `com.unity.services.lobby` | Room creation, matchmaking |
| Relay | `com.unity.services.relay` | NAT traversal for P2P |
| Cloud Save | `com.unity.services.cloudsave` | Server-side player data |
| Leaderboards | `com.unity.services.leaderboards` | Ranked scoreboards |
| Economy | `com.unity.services.economy` | Virtual currencies, purchases |
| Analytics | `com.unity.services.analytics` | Player behavior tracking |
| Matchmaker | `com.unity.services.matchmaker` | Skill-based matchmaking |
Initialize UGS before using any service:
```csharp
await UnityServices.InitializeAsync();
await AuthenticationService.Instance.SignInAnonymouslyAsync();
```
## Firebase and PlayFab
Use Firebase for indie/mobile projects needing Realtime Database, Cloud Functions, and FCM push notifications. Use PlayFab for LiveOps-heavy games needing player segmentation, A/B testing, and automated rule processing. Both provide Unity SDKs via their respective download pages.
## Additional Resources
### Reference Files
- **`references/netcode-advanced.md`** -- Client prediction and reconciliation implementation, interest management, network LOD, bandwidth optimization, custom serialization, transport layer configuration
- **`references/backend-services.md`** -- Detailed UGS setup walkthroughs, Firebase/PlayFab integration patterns, REST API architecture, authentication flows, leaderboard and economy implementation
© JosiahSiegel · MIT · JosiahSiegel/claude-plugin-marketplace