Welcome to the Unity Netcode for Entities samples repository!
Here you can find all the resources you need to start prototyping your own real-time multiplayer games.
The netcode for entities package provides the multiplayer features needed to implement world synchronization in a multiplayer game. It uses the transport package for the socket level functionality, Unity Physics for networked physics simulation, Logging package for packet dump logs and is made for the Entity Component System. Some higher level things it provides are
- Server authoritative synchronization model.
- RPC support, useful for control flow or network events.
- Client / server world bootstrapping so you have clear separation of logic and you can run a server with multiple clients in a single process, like the editor when testing.
- Synchronize entities with interpolation and client side prediction working by default.
- Network traffic debugging tools.
- GameObject conversion flow support, so you can use a hybrid model to add multiplayer to a GameObject/MonoBehaviour based project.
For more information about the netcode package, please see the Netcode for Entities Documentation
A small game featuring the Netcode for Entities Package features.
A small sample featuring the Netcode for Entities Package basic features, this is the sample used in the Getting Started guide in the manual.
A sample using predicted physics based on Unity Physics. The sample is predicting all objects close the the player but not objects far away. The color of the spheres will change to indicate if they are predicted or interpolated.
A sample which shows how to maintain a list of connected players by using the RPC feature.
This is a suite of samples which aim to be small, simple and show features in isolation. Later samples then re-use earlier ones so it's simpler to see exactly what's being shown and similar routines (like connecting, going in game etc) don't need to be repeated. This way samples can also build on top of each other and become more complex. They are split into Basic, Intermediate and Advanced areas depending on level of complexity and how commonly the things shown are needed in a normal project.
To try out samples in this repository all you need to do is open NetcodeSamples/
in Unity.
If you wish to create a new Unity project using the Netcode package that is also possible.
- Minimum supported version is Unity 2022.2.0b8 but it’s recommended to use the latest released 2022.2 version for important fixes
- Create a new URP Unity project
- Navigate to the Package Manager (Window -> Package Manager). And add the following packages using Add package from git URL... under the + menu at the top left of the Package Manager.
- com.unity.netcode
- com.unity.entities.graphics
- Package dependencies will automatically be pulled into the project
At the moment there are two ways of building the samples. You can use the Build Configuration assets or the builtin method using the Build Settings window.
When using the Build Settings window the Builtin Builds Enabled checkbox in the Entities tab in the Editor preferences must be checked. Make sure you have the appropriate player type set int he DOTS tab in the Player Settings. To build the whole sample scene list (with frontend) as a client/server build select the Client as Player type and ClientAndServer as the Netcode client target. To make a client only build select both Client as Player type and Netcode client target. For a server only build switch to the Dedicated Server platform target and select Server as the Player type.