How to Keep Score in a Multiplayer Game with Netcode in DOTS AR

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 Keep Score in a Multiplayer Game with Netcode in DOTS AR."

Full workflows and code to keep score between players in a multiplayer game using Netcode

Click Here for DOTS Tutorial

This gitbook takes you through step-by-step full workflows and code to keep score between players in a multiplayer game using Netcode. Once you've coded along and fully finished the "How To Keep Score in a Multiplayer Game with Netcode" tutorial, you will be able to keep score between players in a multiplayer game using Netcode.

Click Here for DOTS Tutorial

High-Level steps to Keep Score in a Multiplayer Game with Netcode:

Number 01

Update Game UI based on updated ghost values

Number 02

Update ClientServerConnectionHandler to handle quits

Number 03

Remove logs from the Rpc and GameUIManager "Quit game"

FAQ

How do DOTS and MonoBehaviour work together within NetCode in DOTS AR?

NetCode will be handling keeping track of scores of each player in the game. The idea is to take this data from ECS and populate the game UI which runs on MonoBehaviours. In our Tutorial, we demonstrate our approach to pulling data from ECS into MonoBehaviours by using the EntityManager. They key is to understand that a ECS System cannot "push" values directly into a GameObject, instead a MonoBehaviour must "pull" data using an EntityManager.

How do players find games using Netcode in DOTS AR?

In order to do this in our tutorial, we will be using .NET's UdpClient class to send broadcast packets across the local area network's router. This will not work if the player is not connected to WiFi. We will also be using .NET's Thread class to create listening threads for broadcast packets so it does not interrupt Unity's threading.

What are some additional resources for how to use Netcode in DOTS AR?

Unity documentation for Netcode 0.6.0-preview.7: https://docs.unity3d.com/Packages/com.unity.netcode@0.6/manual/index.html Refer to this for more information. Unity samples for NetCode: https://github.com/Unity-Technologies/multiplayer The Asteroids sample is what this gitbook is based off of. Unity thread for NetCode: https://forum.unity.com/threads/dots-multiplayer-discussion.694669/ Unity is responsive here.

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