Netcode For Unity

Almost every multiplayer game should consider and resolve certain network-related issues affecting gameplay. Latency, packet loss, event handling, and gaming solve these problems differently.
Finding solutions depends on the type of game, size of players and connections, competition etc. it depends. How much control do you need over the network infrastructure? Different scenarios require different network code solutions.
This blog discusses the interactive libraries used in the Unity engine and the research results of the developers’ experience with these solutions to help you decide which one is right for your project. help.
What is netcode?
Netcode is the “design” part of the story. Specifically, developers refer to the library, which sends information from one player to another and synchronizes everything with the state of the game. This is also how we deal with light speed limitations and slow data arrivals.
A solution typically includes a transport layer (base layer) that manages all traffic to and from the hardware and a higher level of network code abstraction and vehicle partitioning.
There is no one-size-fits-all solution for every type of game or experience. For example, FPS games like Apex Legends run on game servers with P2P topology, like Heroes Strike, which own the server rights to prevent fraud and decide to roll back to reduce fraud. Network code rules are entirely different from MOBA as it works.
There is no one mesh encoding solution that works for all situations, so developers must weigh their options and decide which solution (or hybrid solution) best fits their gaming needs. It is often necessary to expand or modify existing connection rights.
Unity Netcode Solutions
Unity provides two different first-party network code solutions: Game Object mesh code and Entity mesh code.
Netcode for GameObjects
Netcode for GameObjects is a link library designed for the Unity game engine. The current version of NGO aims to support the development of small cooperative games and using Unity Relay and Unity Lobby solutions works well in such P2P games.
Netcode for Entities
At the other end of the multiplayer development spectrum is Netcode for Sites. It is part of the DOTS ECS (Entity-Component-System) feature set that allows you to create scalable multiplayer worlds for players.
Netcode for assets allows game world dimensions and network interactions, including players, without the penalties traditional developers have to deal with.
Testing Different Network Code Solutions
Unity has written reviews for some of the most commonly used 3rd party network code solutions. We’ve created a decision tree to guide you through the process of deciding which framework is best for you.
To create these tools, Unity collected and analyzed data from three sources:
- A survey asking 200+ Unity users about their experience with the site’s unique framework
- (more than 20 in-depth interviews with people who frequently offer competitive games on Unity Network Code), insights from the designs, mirrors, and photons in DarkRift 2.
1. Stability and Support
Networks are complex, and so is the level of security and support you get from Netcode solutions. The security and support of each Netcode solution are measured along three axes: the probability of errors and crashes, response time to fix or help resolve issues, and impact changes to the API. Compliance tests are carried out.
2. Ease of Use
Write user reviews of how easy it is to start and perform routine tasks, including great examples, documentation, tips, and solutions, and provide an easy-to-use API for the build model.
3. Performance
Who needs a low-performance solution? We take great care with limited GC/deployment, minimal latency overhead, high compute performance, and multiple threads to achieve this across all network solutions evaluated.
4. Scalability
Depending on the type of game you are creating, the scalability of your Netcode solution is an important consideration. In terms of performance, we evaluated the solution’s ability to support multiple connected clients without a significant performance impact.
5. Full-featured
Having an efficient network code solution is essential to support the unique needs of any type of project or a particular game. Our solution focuses on intermediate features such as objects and variables, RPC and event management. I’m still looking for more advanced features like forecasting and business payments.
6. Cost
Unity also conducted a cost analysis for each solution in order to allocate a budget for Netcode’s solutions. This includes credit/solution costs as well as hidden costs such as overheads that must be managed separately.
Which netcode solution is right for you?
Before we move on to our findings and recommendations, it is important to address our main point.
First of all, choosing a network encoding solution for your game is a big decision and you should do your own evaluation as well. We hope to make the process easier for you by sharing most options, but you should make your own judgment based on the specifics of your activity. It does not represent a choice. Especially in the migration process, there are many solutions such as Enet, LiteNetLib, Ruffles, and Telepathy.
Third, this information comes from research in 2020, and more research will be needed to fully understand the solutions available today.
The file below is just a start, but we recommend that you also download the full Netcode report. Let’s take a closer look at third-party Netcode solutions:
- MLAPI (now acquired by Unity and evolved into Netcode for GameObjects)
- DarkRift 2
- Photon PUN
- Photon Quantum 2.0
- Mirror
High-level guide to starting to evaluate a netcode solution
We have created a chart to show you the process of this important decision. Note that all abstractions omit important details. While we can’t tell you all the changes that will affect your decision, here are some things to consider as you begin to evaluate solutions that will help you complete your game.
Here’s a quick look at some key terms used in decision trees and what they mean.
- Dedicated Game Server (DGS): Using a client-server network where the server is hosted on a dedicated computer. H. Uninstall from Client Devices. This option is expensive, but scalable and secure.
- Listening Server: A client application where the server is hosted on the client.
- It is inexpensive, but not scalable and insecure.
- Deterministic key step: In the P2P application, only things are sent to all players and synchronized with the “key step” (i.e. the same analogue beacons every time). The system is cheap and safe, but certainly complex.
- Deterministic Rollback: An extension of the deterministic lockstep that predicts input while users are waiting for updates. This setup is more complex but allows for more gameplay than key steps. The price is cheap and safe, but stable and very difficult to simulate.
View the full report for analysis details
https://create.unity.com/form-netcode-report
Netcode supports the following versions:
- Unity 2020.3, 2021.1, 2021.2, 2021.3, and 2022.
- Mono and IL2CPP Scripting Backends
Netcode supports the following platforms:
Windows, macOS, and Linux
- iOS and Android
- XR platforms running on Windows, Android, and iOS operating systems
- Most closed platforms, such as consoles.
- If you use a console (PlayStation, Xbox, Nintendo Switch, etc.), there may be netcode specific guidelines that you should be aware of when testing and before launching your game live. See the console’s internal documentation for more information. This content is usually protected by an NDA.
Note:
Netcode does not support the WebGL platform as it does not allow access to IP sockets.
The community supported a third-party relay that allowed the communication to be used with the WebGL platform.
Use with caution:
- Using Netcode with WebGL can cause errors and problems, it’s not important to fix them.
- The server or host cannot be a WebGL client. It can be desktop or mobile.
- Potentially increased latency and jitter due to the TCP protocol used by WebSockets.
Getting started with multiplayer development in Unity
Whether you’re creating your next battle royale smash hit or creating a comfortable online co-op experience, understanding the basics of multiplayer networking and the netcode solutions at your disposal is essential.
Check out Unity’s Netcode for GameObjects solution, Boss Room co-op sample, and documentation to get started on your next multiplayer project today. If you want to create a massively multiplayer game, check out our Battle Royale example using Photon Fusion and Game Server Hosting.
Enjoy your creations.
Ready to bring your Unity game vision to life?
Expert App Devs connects you with top-tier Unity developers in India, offering exceptional value and peace of mind:
Affordable Expertise:
- Hire skilled Unity developers at a competitive hourly rate of just $22.
- Simplify budgeting with a fixed monthly cost of $2500.
Collaborative Excellence:
- Benefit from a free shared project manager to ensure seamless communication and workflow.
- Experience the agility and expertise of a dedicated team working in sync with your goals.
Secure and Transparent:
- Safeguard your project with a strict non-disclosure agreement (NDA).
- Build trust and confidence with a 1-week risk-free trial to assess developer fit.
Why Choose Expert App Devs for Your Unity Game Development?
- Access a pool of pre-vetted Unity experts, proficient in C#, JavaScript, object-oriented programming, and Unity features.
- Enjoy seamless collaboration with developers who seamlessly integrate with UI, graphics, scripting, and other teams.
- Benefit from proactive project management ensuring timely delivery and quality outcomes.
- Tap into a team experienced in diverse Unity projects, from 2D and 3D games to multi-platform and multiplayer experiences.
Ready to kickstart your project?
Visit expertappdevs.com today or reach out to us for a personalized consultation. Let’s create immersive gaming experiences together!




