This "Hello World" guide walks you through creating a project, installing the MLAPI package, and creating the basic components for your first networked game.
- Open the Unity Hub.
- Click New.
- Select type ‘3D’
- Rename the project "Hello World".
- Select the location to save the project.
This tutorial requires an MLAPI-supported version of Unity (2019.4+).
See the Install MLAPI guide to install the MLAPI package.
Right click in the Hierarchy tab of the Main Unity Window.
Select Create Empty.
Rename the GameObject NetworkManager.
We renamed the GameObject because:
- It makes it easier to refer to later.
- There is one and only one NetworkManager, this is the object that contains the
You have now created a new GameObject called NetworkManager.
Click Add Component in the Inspector Tab.
Select MLAPI from the list shown.
NetworkManagerComponent from the list displayed.
NetworkManagercomponent tab, locate the
Click "Select Transport".
Create 3D Object->Capsule (name it Player).
Click the Assets folder.
Create a new Folder and call it Prefabs.
Make Player a prefab by dragging it to Prefabs folder you just created.
Delete Player from scene.
We remove Player, because we will be using the network library to spawn the player. The library cannot track objects that start in the scene.
Add Player prefab to
NetworkPrefabslist inside of
Select Default Player Prefab.
When you select the Default Player Prefab , you are telling the library that when a client connect to the game, automatically spawn this prefab as the character for the connecting client. If you do not have the default selected for any prefab the game will crash on client connect.
You may see the following error reported
There is no NetworkPrefab Marked as a PlayerPrefab. Once you have completed the above steps you can clear the error.
Create a 3D Object->Plane, centered at (0,0,0).
Click Start Host under NetworkManager.
Congratulations you have created a networked game. It is not a very flashy game but it is a networked game nonetheless. For the next steps in your journey see Building on "Hello World"