How to Create a Socket Connection using NetCode in ECS XR

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 Create a Socket Connection using NetCode in ECS XR."

Full workflows and code to create a server/client socket connection using NetCode

Click Here for DOTS Tutorial

This gitbook takes you through step-by-step full workflows and code to create a server/client socket connection using NetCode. Once you've coded along and fully finished the "How To Create a Socket Connection using NetCode" tutorial, you will be able to create a server/client socket connection using NetCode.

Click Here for DOTS Tutorial

High-Level steps to Create a Socket Connection using NetCode:

Number 01

Add the NetCode package and create ClientServerConnectionControl

Number 02

Update IP address and port to be provided by GameObjects

Number 03

Trigger a client server connection through GameObjects with tags

FAQ

What is Netcode in ECS XR?

Unity's DOTS NetCode is a dedicated server with client prediction networking model. Overview of Unity's decision to move to this type of network architecture, "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 ECS XR?

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 ECS XR?

"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