unity-multiplayer
Installation
SKILL.md
unity-multiplayer
Core Philosophy
Multiplayer game programming is an exercise in distributed systems operating under the constraints of physics and latency. You cannot trust the client; anything calculated on a player's machine—hit detection, movement speed, inventory transactions—will inevitably be hacked. High-performance Unity multiplayer requires a server-authoritative model with Netcode for GameObjects (NGO), Unity Relay & Lobby for NAT traversal, and client-side prediction with server reconciliation to mask network latency for players.
4-Step Unity Multiplayer Architecture
Step 1: Topology & Transport (NGO + Relay + Lobby)
- Network Topology:
- Dedicated Game Server (DGS): Absolute authority, zero host advantage, highest server cost. Best for competitive matchmaking.
- Listen Server / Host-Client: One player acts as both host and server. Zero server cost, but host has 0ms latency advantage.
- Unity Transport & Relay:
- Use Unity Transport Package (UTP) combined with Unity Relay service to pierce corporate firewalls and symmetric NATs without requiring players to configure router port forwarding.
- Unity Lobby:
- Handles room matchmaking, player slot reservations, and custom lobby metadata before spinning up the network transport.