plugins/unity-master/skills/unity-networking/SKILL.md
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.
npx skillsauth add JosiahSiegel/claude-plugin-marketplace unity-networkingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.
| 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 |
com.unity.netcode.gameobjectsNetworkManager to a scene GameObjectNetworkObject component| 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 |
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 |
// 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:
_health.OnValueChanged += (oldVal, newVal) => healthBar.value = newVal;
| 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 |
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.
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
// Server-side spawning
var instance = Instantiate(prefab, spawnPoint, Quaternion.identity);
instance.GetComponent<NetworkObject>().SpawnWithOwnership(clientId);
// Server-side despawning
networkObject.Despawn(); // Removes from all clients
Use NetworkManager.SceneManager.LoadScene("GameScene", LoadSceneMode.Single) for synchronized scene loading. Only the server/host should call this.
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.
For real-time non-game communication (chat, notifications), use a WebSocket library. NativeWebSocket works across platforms including WebGL.
| 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:
await UnityServices.InitializeAsync();
await AuthenticationService.Instance.SignInAnonymouslyAsync();
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.
references/netcode-advanced.md -- Client prediction and reconciliation implementation, interest management, network LOD, bandwidth optimization, custom serialization, transport layer configurationreferences/backend-services.md -- Detailed UGS setup walkthroughs, Firebase/PlayFab integration patterns, REST API architecture, authentication flows, leaderboard and economy implementationdevelopment
This skill should be used when the user asks to train, debug, scale, or improve ML models. PROACTIVELY activate for: (1) PyTorch, TensorFlow/Keras, JAX, Flax, Hugging Face Trainer/Accelerate training loops, (2) distributed training, DDP/FSDP/DeepSpeed, TPU/GPU setup, (3) mixed precision AMP/bf16, gradient accumulation, checkpointing, seeding, (4) overfitting, imbalance, loss functions, regularization, LR schedules, warmup, (5) memory optimization, gradient checkpointing, offloading, quantization-aware training. Provides: reproducible training best practices across deep learning and classical ML.
development
This skill should be used when the user asks to productionize, track, version, govern, monitor, or automate ML systems. PROACTIVELY activate for: (1) MLflow, Weights & Biases, Neptune, Comet, ClearML experiment tracking, (2) model registry, model versioning, artifact lineage, reproducibility, (3) Kubeflow, SageMaker Pipelines, Vertex AI Pipelines, Azure ML pipelines, Databricks workflows, (4) CI/CD, continuous training/evaluation, A/B tests, canary/shadow deployments, (5) drift detection, model monitoring, data validation, responsible AI governance. Provides: end-to-end MLOps architecture and operational safeguards.
development
This skill should be used when the user asks to optimize, export, serve, compress, or accelerate ML inference. PROACTIVELY activate for: (1) latency, throughput, p95/p99, batching, concurrency, KV cache, memory, or cost issues, (2) quantization INT8/INT4, GPTQ, AWQ, bitsandbytes, pruning, sparsity, distillation, (3) ONNX export, ONNX Runtime, TensorRT, TorchScript, torch.compile, XLA, OpenVINO, Core ML, TFLite, (4) Triton, TorchServe, TF Serving, BentoML, Seldon, KServe configuration, (5) edge deployment, CPU/GPU/TPU/Inferentia serving. Provides: hardware-aware inference optimization and safe benchmarking.
testing
This skill should be used when the user asks to tune hyperparameters, run sweeps, optimize search spaces, or use AutoML. PROACTIVELY activate for: (1) Optuna, Ray Tune, FLAML, AutoGluon, Hyperopt, Nevergrad, KerasTuner, W&B sweeps, (2) grid search, random search, Bayesian optimization, TPE, Gaussian processes, evolutionary search, (3) ASHA, Hyperband, successive halving, multi-fidelity optimization, population-based training, (4) learning-rate finder, batch-size search, early stopping, pruning, (5) reproducible sweep design and experiment analysis. Provides: budget-aware hyperparameter search strategy.