Netcode Plus

NetcodePlus is an extension of Unity’s Netcode for GameObjects.

For documentation on the original Netcode, you can check here: https://docs-multiplayer.unity3d.com/netcode/current/about/index.html

Instead of using NetworkObject and NetworkBehaviour components, this assets uses SNetworkObject and SNetworkBehaviour. It is still possible to use the original NetworkObject component in your project, but it should not be on the same objects that uses the new ones.

What has changed in NetcodePlus?

-Components (SNetworkObject, SNetworkBehaviour)

-Spawn System

-Network Action System (SNetworkActions replacing RPC calls)

-Network Variables (SNetworkVariable)

What has NOT changed?

-Transport Layer (Unity Transport)

-Scene Management

-Messaging & Serialization

What is new?

Built-in way to create a Dedicated Game Server

Built-in way to create a Dedicated Lobby Server

Improved Connection Process that allow easily transferring data before the game starts.

Easy Integration with other systems (Relay, Authentication...)

Some cool demos and examples

Why the new components?

-The Original Netcode would try to send all network variables of all spawned object to a newly connected client, which would often be over the message size limit for a big scene. In NetcodePlus you can control when and which variable are sent when a new client connects, Spawn requests will be batched into small groups instead of sent all at the same time.

-Scene objects are not spawned until the full new connection process is completed, allowing players to transfer data between them before the objects and player start spawning. This is extremely useful to share save files or other initialization data before all scene objects start syncing.

-By adding the SNetworkOptimizer component to a prefab, the game will automatically sync (spawn) objects that are near the players, and stop syncing (despawn) the ones that are far (you can set the distance). Which greatly improve performances.

-NetcodePlus includes a new feature: Network Actions. A way to remotely call functions that is written in pure C# (no [tags] and no code generated at compilation, like it is the case with RPC calls). It streamlines function calls and syncing variables, since both can be done the same way.

-A Network Action can also be triggered to run on both the server and client in one call, and will work even if the object isn't spawned, which can help having scripting consistency between playing peer-to-peer, on a dedicated server or offline (a ClientRpc would run locally on a p2p host but not on dedicated server, and not run at all if the object isn't spawned. So Rcp require more effort to handle each different kind of server in the code). This avoids having a lot of if(isSpawned) DoSomethingRpc() else DoSomething() in your code.

-Another advantage of Network Actions is that actions initiated from a client that should be executed by another client will first be sent to the server and be automatically forwarded to the correct recipients by the server, without the need to add specific code for this.

You should use Network Actions instead of RPC calls with SNetworkObject, the same things can be achieved, just in a different way and with more options. Note that you can still use RPC calls on objects with the original netcode NetworkObject component. Do not put both components on the same object, it will not work. Although you can have both on different objects in the same scene. Keep in mind that regular NetworkObject will be spawned before the new connection process finishes..

Last updated