Use when adding or reviewing networking in a Unity game: choosing between Unity Netcode (GhostObjects or entities) and Netcode for GameObjects, the authority model, host modes, sessions, matchmaking, relay, dedicated server builds, or testing several peers with Multiplayer Play Mode.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Unity Multiplayer?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/firzus-unity-multiplayer)
---
name: unity-multiplayer
description: >-
Use when adding or reviewing networking in a Unity game: choosing between
Unity Netcode (GhostObjects or entities) and Netcode for GameObjects, the
authority model, host modes, sessions, matchmaking, relay, dedicated server
builds, or testing several peers with Multiplayer Play Mode.
---
# Multiplayer: netcode, authority, sessions, dedicated server
Load the [`unity-core`](../unity-core/SKILL.md) skill with this one: its default
stack and review pass apply here.
Networking is decided before gameplay code exists: the netcode stack, the
authority model, and the client/server split shape prediction, state ownership,
and the build pipeline. Retrofitting any of the three is a rewrite.
For engine-agnostic replication theory and drop-in co-op session design, use the
`coop-session` skill. For server-authoritative persistence, use
`save-persistence` and `inventory-equipment`.
## The stack
| Concern | Package |
| --- | --- |
| Netcode | `com.unity.netcode` (Unity Netcode) |
| Sessions, Lobby, Relay, Matchmaker | `com.unity.services.multiplayer` |
| Server builds | `com.unity.dedicated-server` |
| Multi-peer testing | `com.unity.multiplayer.playmode` |
The netcode is **Unity Netcode** with GhostObjects. Leave it only in these
situations:
| Situation | Netcode |
| --- | --- |
| Gameplay already on ECS, or ghost counts where per-object cost dominates | Unity Netcode, entity workflow, mixed with GhostObjects |
| Distributed authority | Netcode for GameObjects |
**Unity Netcode** carries an entity workflow and a GameObject workflow in one
package. Its namespaces and types are spelled `Netcode`
(`using Unity.Netcode;`), while its assemblies are named `Unity.NetCode*` in
asmdef references.
**GhostObjects** are its GameObject workflow. A GhostObject component on the
prefab root makes a GameObject networked. Gameplay goes in `GhostBehaviour`
scripts (`PredictionUpdate`, `PredictionGatherInput`,
`PredictionPhysicsUpdate`), replicated state in `GhostField<T>`, input in
`GhostInput<T>`, one-off events in RPCs or custom messages, and session start in
the static `Netcode` class (`Listen`, `Connect`, `StartAsHost`). Only the
transform, and the Rigidbody on predicting clients, replicate on their own: a
value that no `GhostField<T>` or `GhostComponentRef<T>` declares never reaches
clients.
**The entity workflow** costs less per object: each GhostObject syncs its
transform with its ghost entity every frame and runs its `GhostBehaviour`
methods in managed code that Burst cannot compile. Both workflows share one
replication pipeline and mix in one world, so keep most objects as GhostObjects
and move the mass ones (mobs, projectiles) to entity ghosts, or put their hot
data in a `GhostComponentRef<T>` that a Burst system processes.
**Netcode for GameObjects** (`com.unity.netcode.gameobjects`, NGO:
`NetworkBehaviour`, `NetworkVariable`, and RPCs) installs Unity Netcode,
Entities, Burst, and Collections as dependencies. Its time types (`NetworkTime`,
`NetworkTimeSystem`, `NetworkTickSystem`) live in
`Unity.Netcode.GameObjects.Timing`, and its Editor assemblies are
`Unity.Netcode.GameObjects.Editor*`.
## Authority
**Client-server** is the default: the server owns simulation and is the source
of truth for anything exploitable (position validation, damage, inventory,
economy), while clients predict and render. Unity Netcode supports no other
model: every ghost belongs to the server, dedicated or run by a host player,
and a client's write to a predicted value is a prediction the server
overwrites.
In a `GhostBehaviour`, guard server-only decisions such as spawning or scoring
with `IsServer`, and writes to predicted state with `CanWriteState` (true on the
server and on predicting clients). Keep `PredictionUpdate` identical on server
and clients: branching there on `IsServer` makes them run different code and
mispredict. A host is both server and client, so write the two cases as
independent `if` statements; an `if (IsServer) {...} else {...}` never runs
the client branch on a host.
A Unity Netcode host runs in **single-world host mode** by default: one world
for client and server, cheaper for the host, but without prediction switching,
partial ticks, or relevancy on the host connection. GhostObjects support only
this mode, so keep it in any project that has GhostObjects. A dedicated server
build stays possible: it starts with `Netcode.Listen` whatever the host mode,
and testing against a dedicated server exercises the server code paths the
single-world host skips. **Binary-worlds host mode** (**Host World Mode
Selection** on the `NetcodeConfig` asset) runs separate client and server worlds
on the host, matching a dedicated server's code paths; it fits only a game
entirely on the entity workflow.
**Distributed authority** exists only in NGO, so choosing it also chooses the
netcode package. It spreads `NetworkObject` ownership across clients through a
relay: owners simulate their own objects, ownership transfers or redistributes
automatically, and object state survives a client leaving. One client is the
session owner, handling global operations such as network scene management. It
fits drop-in co-op, social spaces, and sandboxes without a simulation server.
Competitive games stay client-server, where centralised anti-cheat,
server-authoritative physics, and rollback live.
Under distributed authority, gate authoritative logic on
`NetworkBehaviour.HasAuthority`, which reads `true` on the owning client.
`IsServer` answers a different question and silently does the wrong thing
there.
Validate client input and rate-limit state changes under either model: a client
owning an object still means a client controls what it reports.
Setup for distributed authority: Netcode for GameObjects with no GhostObject on
its network prefabs (a prefab carrying both a NetworkObject and a GhostObject
makes the session fail to start), `com.unity.services.multiplayer`, a Unity
Cloud project, and a session created `WithDistributedAuthorityNetwork()`.
## Sessions and services
**Multiplayer Services** consolidates Lobby, Relay, and Matchmaker into one SDK
with a higher-level `sessions` API, which is why connection flows go through it
rather than the individual services or hand-rolled sockets.
With Unity Netcode, the SDK's session host calls `Netcode.StartAsHost`, which
follows the `NetcodeConfig` host mode, only when the scripting define
`NETCODE_GAMEOBJECT_BRIDGE_EXPERIMENTAL` is set, although Unity Netcode 7.2 no
longer needs that define for GhostObjects. Without it, Multiplayer Services 2.5
hosts with separate client and server worlds, which GhostObjects don't support.
Add the define to every build that hosts a session until the SDK drops this
condition.
- Matchmaker supports CEL OR-operator pools and filters, config history with diffs, dashboard log access, and third-party hosting hooks.
- Cloud Code has an experimental stateful mode with a local server for per-player and per-session state, which prototypes persistence before dedicated servers exist.
- Build session UI on **Unity Building Blocks**.
- Host dedicated servers with a third-party provider, connected through the Matchmaker's hosting hooks.
**Multiplayer Center** (`Window → Multiplayer → Multiplayer Center`) scaffolds
packages, samples, and tutorials from a questionnaire. It is a pre-release
package, and Unity's own docs advise backing up the project before installing its
recommendations, since they can conflict with multiplayer packages already
present. Point it at new projects; wire an existing codebase by hand.
## Server builds
Use the **Dedicated Server** platform with **Multiplayer Roles**
(Edit → Project Settings → Multiplayer) to produce Client, Server, and
Client-and-Server builds from one project. Roles strip rendering, UI, and audio
from server builds automatically, which is what keeps headless builds small and
cheap to run.
Drive server builds through Build Profiles with per-role scene lists and
scripting defines, and run them in CI like any other target — see
[workflow.md](../unity-core/workflow.md).
## Testing
**Multiplayer Play Mode** runs multiple virtual players in
one Editor, so host-and-client behaviour is testable without several Editor
installs or standalone builds. Its capabilities live largely in the Play Mode
Framework and the engine's Multiplayer modules. Each developer's local player
run mode is stored per developer, not in the shared scenario asset.
Activate a virtual player with its checkbox in the Multiplayer Play Mode
window, or ask the user to tick it; never edit `Library/VP/SystemData.json`.
A player's `Active` flag there records that its clone Editor is running, not
a request to start one. Activation returns without launching anything while
the flag reads `true`, and the Editor recomputes the flag at startup only for
a player that already has a clone. A flag set by hand therefore stays `true`:
the window shows the player unticked, and ticking it starts nothing.
Trust the running instances, not the file:
`unity command editor.playmode list_instances` lists each running clone
(`role: clone`, its port and `vpId`), and `unity command --instance <name>`
sends a command to one. When the file reads `Active: true` for a player that
`list_instances` does not show, the user closes the Editor, sets that player's
`Active` back to `false`, and reopens it; this repair is unverified.
The scenario commands (`editor.playmode create_scenario`, `add_player --type
clone`, `set_active_scenario`, `start_scenario`, `get_scenario_status`) may
start clones without the window. This path is unverified: confirm each clone
with `list_instances` before relying on it.
With Unity Netcode, the **PlayMode Tools** window
(`Window → Multiplayer → PlayMode Tools`) sets the role that entering Play mode
starts: **Client**, **Server**, or **Client & Server**, a host in one world under
single-world host mode; in a Multiplayer Play Mode scenario, set this PlayMode
Type in each player's window. When
`com.unity.dedicated-server` is installed, the player's Multiplayer Role
overrides it. Test as a host and as a dedicated server, since a host takes both
`IsServer` and `IsClient` branches.
With `com.unity.pipeline` installed, Unity Netcode registers `unity command`
groups under `netcode` that inspect worlds, connections, and ghosts, compare a
ghost's state on the server and clients, control the network simulator, and
record prediction traces; NGO registers `netcode.gameobjects` groups. Run them
as [unity-cli](../unity-cli/SKILL.md) describes.