$ show Unity-Technologies/com.unity.multiplayer.samples.coop
This repository is a complete multiplayer co-op game sample called 'Boss Room', built by Unity Technologies to demonstrate best practices for using Unity Netcode for GameObjects (NGO). It implements a server-authoritative action RPG where up to 8 players cooperate to defeat a boss in a dungeon. The architecture is modular and state-driven: a connection state machine (Offline, ClientConnecting, Hosting, etc.) manages network lifecycle, while game flow states (MainMenu, CharSelect, BossRoom, PostGame) control scene transitions and gameplay logic. The core gameplay revolves around a ScriptableObject-based action system where abilities (melee, projectiles, buffs, stealth, etc.) are defined as data assets and executed via server-side action players with client-side anticipation for latency masking. The project integrates Unity Gaming Services for authentication, session management, and relay, and uses VContainer for dependency injection. Key entry points include ApplicationController (DI setup), ConnectionManager (network state machine), and GameStateBehaviour subclasses. Data flows involve client input sent via RPCs, server-side processing with NetworkVariables for state sync, and a typed NetworkedMessageChannel for decoupled event broadcasting. External dependencies include Unity Netcode, Unity Transport, Unity Gaming Services, VContainer, Cinemachine, and URP.
The LLM identified 4 files worth highlighting for reuse:
A generic typed message channel that works over the network using Unity Netcode's CustomMessagingManager. It allows server-to-client broadcasting of strongly-typed messages (e.g., LifeStateChangedEventMessage) without coupling senders to receivers. The implementation handles serialization, deserialization, and subscription management. This pattern is reusable in any Netcode project for decoupled networked events.
A network-aware object pool for NetworkObjects. It prewarms a configurable number of instances, handles spawning and despawning via Netcode's NetworkObjectPool, and returns objects to the pool on despawn. This reduces allocation and network overhead for frequently spawned objects like projectiles. The pattern is self-contained and can be extracted into any Netcode project.
The base class for all game actions (abilities). It defines a lifecycle with OnStart, OnUpdate, End, Cancel, and ChainIntoNewAction methods, and uses ScriptableObject for data-driven configuration. Subclasses implement specific behaviors (melee, projectile, buff, etc.). The pattern demonstrates a clean separation of action data (ActionConfig) from runtime logic, and is reusable as a foundation for any ability system in Unity.
The base class for a hierarchical state machine managing network connection lifecycle. Subclasses (OfflineState, ClientConnectingState, HostingState, etc.) implement specific behaviors for each connection phase. The pattern encapsulates state transitions, error handling, and reconnection logic. It is a clean, reusable implementation of the state pattern for network connection management in Unity.