How to Get Started with Netcode in Unity ECS

This will take you about 20 minutes in prep time if you don't have Unity set-up, and 30 minutes in coding and debug time.

Click Here for DOTS Tutorial

Stop struggling with the limited documentation. Follow this step-by-step tutorial: "How to Get Started with Netcode in Unity ECS."

Full workflows and code to spawn and destory ghost entities and interact with Thin Clients through PlayMode Tools

Click Here for DOTS Tutorial

This gitbook takes you through step-by-step full workflows and code to spawn and destory ghost entities and interact with Thin Clients through PlayMode Tools. Once you've coded along and fully finished the "How To Get Started with Netcode" tutorial, you will be able to spawn and destory ghost entities and interact with Thin Clients through PlayMode Tools.

Click Here for DOTS Tutorial

High-Level steps to Get Started with Netcode:

Number 01

Create a socket connection and navigate multiple ECS Worlds

Number 02

Load a game on the client using NetworkStreamInGame component

Number 03

Create networked entities called Ghosts and proper NetCode entity destruction

FAQ

What is Netcode in Unity ECS?

Unity's DOTS NetCode is a dedicated server with client prediction networking model. For an overview of Unity's decision to move to this type of network architecture, read "Navigating Unity's multiplayer Netcode transition": https://blogs.unity3d.com/2019/06/13/navigating-unitys-multiplayer-netcode-transition/

What is the Server World and the Client World in Unity ECS?

NetCode has a separation of client and server logic, and both the client and server logic are in separate Worlds (the client World, and the server World), based on the hierarchical update system of Unity’s Entity Component System (ECS). In Unity's authoritative server client-predicted network architecture, the server is the authoritative source of the game. So if the client "predicts" a response to an input and the server disagrees, the server wins.

What are Ghost entities in Unity ECS?

"Ghost" is the Unity term for entities whose state the server sends to the client (a networked object). The server keeps track of all Ghosts and then sends "snapshots" of their Component's "Ghost Fields". In Moetsi's sample project, Players, asteroid entities, and bullet entities will all be ghosts. Their state will be sent by the server to the clients by what unity calls "snapshots". Once the clients receive the snapshots the asteroids entities will have their state updated.

Haven’t begun learning Unity DOTS yet, and need to start at the very beginning?

If you haven't yet dipped your toes into learning Unity's new multithreaded Data-Oriented Technology Stack (DOTS), now is the time. You can start at the very beginning with Moetsi’s tutorial, which culminates in your very own deployable sample project. You’ll be guided by full workflows, code-alongs, videos, and GIFs along the way.

Get Started