A small, deliberately-readable multiplayer sample built with Unity 6 (6000.4) and Netcode for GameObjects (NGO) 2.x. It demonstrates a server-authoritative architecture: the server is the single source of truth, clients send intent rather than state, and no client can move itself or spawn objects directly.
Built as a focused reference for how I structure networked gameplay — clean assembly boundaries, one place that owns connection flow, and server-authoritative movement and spawning that a client can't cheat.
- Server-authoritative movement — the owning client samples input and sends it to the
server via RPC; the server simulates and a
NetworkTransformreplicates the result. - Server-authoritative spawning — players are spawned by the server on connect; a generic spawner lets clients request objects (e.g. monster waves) while the server decides whether to honour the request.
- Centralised connection flow — a single
ConnectionManagerwrapsNetworkManager(host / client / server, connection approval) so UI and tests never touch it directly. - Replicated game state — a
NetworkVariable-driven state machine (Lobby → InGame → GameOver), server-writable only. - Custom URP shaders (hand-written HLSL) — purpose-built for the demo rather than a
generic collection:
PlayerHighlight— fresnel rim glow to distinguish the locally-owned player.HitFlash— flash-to-colour hit feedback, driven from script via aMaterialPropertyBlock(no per-instance material, stays batchable).Dissolve— noise dissolve with an emissive edge for spawn / despawn.
Owning Client Server (authority) Other Clients
───────────── ────────────────── ─────────────
sample input ──SubmitInputRpc──▶ validate + simulate movement
write NetworkTransform ──replicate──▶ receive state
request spawn ─RequestSpawnRpc─▶ validate + Spawn() ────replicate──▶ receive object
GameState NetworkVariable ─replicate─▶ react to state
Assets/_Project/
Scripts/
Runtime/ (asmdef: Netcode.Demo.Runtime)
Core/ GameBootstrap, GameState, GameStateController
Networking/ ConnectionManager, DevConnectionUI
Gameplay/
Player/ PlayerController (server-authoritative movement)
Spawning/ PlayerSpawner, NetworkObjectSpawner
Effects/ HitFlashEffect (drives the HitFlash shader)
Editor/ (asmdef: Netcode.Demo.Editor) — tooling
Tests/ (asmdef: Netcode.Demo.Tests) — edit-mode + future NGO integration tests
Art/
Shaders/ PlayerHighlight, HitFlash, Dissolve (URP HLSL)
Scenes/ Bootstrap scene (create in-editor — see Setup)
Prefabs/ Player / spawnable network prefabs (create in-editor)
Code is split into its own assemblies rather than living in Assembly-CSharp, so
compile times stay low and dependencies are explicit.
- Unity 6000.4.9f1 (or a matching Unity 6 release)
- Netcode for GameObjects
2.2.0(already listed inPackages/manifest.json) - Recommended: Multiplayer Play Mode and Multiplayer Tools (network profiler), installable from the Package Manager / Multiplayer Center window.
- Open the project in Unity 6. On first open the Package Manager resolves NGO automatically.
- Create a Bootstrap scene with a single GameObject that has:
NetworkManager(assign a transport — Unity Transport is added with NGO)ConnectionManager+DevConnectionUIPlayerSpawner(assign the player prefab and spawn points)
- Create a Player prefab:
NetworkObject+NetworkTransform(server-authoritative)CharacterController+PlayerController. Register it in theNetworkManagernetwork prefabs list.
- Enter Play Mode and press Host, or use Multiplayer Play Mode to run a host and a client side by side.
- Server-authoritative movement, spawning, connection flow, replicated game state (architecture)
- Custom URP shaders (player highlight, hit flash, dissolve)
- Player prefab + Bootstrap scene wired in-editor
- Materials + demo meshes using the shaders, with capture GIFs in this README
- Client-side prediction / reconciliation on the player controller
- Relay + Lobby (Unity Gaming Services) for online play beyond LAN
- NGO integration tests (
NetcodeIntegrationTest) covering spawn + ownership - Network profiler capture in the README (bandwidth per object)
See LICENSE.