Unity 3D – Netcode – part 001.

By | 24/09/2022

The purpose of this tutorial is to test the Netcode packet and any errors that may occur.
This first tutorial only covers the functionality of the packet without implementations of sending data between client and server.
I used the newest version of Unity Hub version 3.3.0 and Unity version 2021.3.9f1.
here and here.
Here are the steps taken in brief:
I created a folder for my projects called Unity3DProjects and I set it for each new project.
I created a new project using Unity Hub called Netcode001.

After creation, the Unity 3D editor will open and if there are problems with the license, then you will have to download the license from your Unity 3D account or obtain/activate a new one.
I use a free Personal Edition license renewed and reactivated on Wed, Dec 20, 2017, my old license when I started working with Unity was around 2013.
These things are important for the learning part because the development of the Unity 3D game engine had substantial changes and a lot of bugs. That’s why not all tutorials cover all the issues needed to develop a game and some elements are still in the development process.
Another element you have to take care of is the interaction with the Visual Studio Community, I received errors when changing the version from 2019 to the new version 2022. The generation of build errors sent me to a new empty folder and I fixed it by reopening the project again without Visual Studio, obviously after it has already been set in the Unity 3D editor.
The setting is made from the File – Preferences menu

The installation of the Netcode package is done from the main menu: Window – Package Manager:

Click the plus sign Add in the Package Manager status bar and select Add package by name… and fill with:

Wait for the package to be installed.

Using the right-click in the Hierarchy tab of the main Unity Window.
Select Create Empty and rename the GameObject with NetworkManager.

With this Unity game object, use click to Add Component in the Inspector Tab.
Search and select Netcode from the list shown.
Select NetworkManager Component from the list displayed and inside the NetworkManager component tab, locate the NetworkTransport field, and add these two scripts.

You need to check if the Select Transport is on the Select UnityTransport.
You can see also my scene has some new objects like a plane and a new game object named NetworkCommandLine.
You can add these two game objects, the plane at the root of the hierarchy and the NetworkCommandLine at the NetworkManager game object.
On the NetworkCommandLine game object use Add Component in the Inspector Tab to add a new C# script named NetworkCommandLine, see the source code:

Save this scene with a name into your folder project.
Use the main menu File – Build Settings… to build into executable into your project folder.
According to the second tutorial, you can test like a client or server with or not logging process.

If you use a text editor you can see all logging processes and steps.
You can see I have an old computer …

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.