Skip to main content

Your First Networked Game "Hello World"

A "Hello World" program is a computer program that outputs or displays the message "Hello, World!". Normally it is the first program written by people learning to code. It is also used as a sanity test to make sure that a computer language is correctly installed, and that the operator understands how to use it.

This "Hello World" tutorial walks you through creating a project, installing the MLAPI package, and creating the basic components for your first networked game.


This tutorial requires an MLAPI-supported version of Unity (2019.4+).

Create a new project in Unity#

  1. Open the Unity Hub.
  2. Click New.
  3. Select type ‘3D’
  4. Rename the project "Hello World".
  5. Select the location to save the project.

Import MLAPI Package via URL#

See the Install MLAPI guide to install the MLAPI package.

Create the Basic Components#

In this section we will create the basic building blocks of a multiplayer game.

Creating Network Manager and selecting the Transport#

In this section we will add a Network Manager and add a Transport to our project.

  1. Right click in the Hierarchy tab of the Main Unity Window.

  2. Select Create Empty.

  3. Rename the GameObject NetworkManager.


    We renamed the GameObject because:

    • It makes it easier to refer to later.
    • There should only be one NetworkManager, this is the object that contains the NetworkManager component. You may get unexpected results if you create more than one NetworkManager.

    You have now created a new GameObject called NetworkManager.

  4. Select NetworkManager.

  5. Click Add Component in the Inspector Tab.

  6. Select MLAPI from the list shown.

  7. Select NetworkManager Component from the list displayed.

  8. Inside the NetworkManager component tab, locate the NetworkTransport field.

  9. Click "Select Transport".

  10. Select UnetTransport.

  11. Save your scene.

Creating an object to spawn for each connected player#

This section adds in a player object and spawns it for each connected player.

  1. Create a 3D Object->Capsule

  2. Rename it Player.

  3. Add a NetworkObject component.

  4. Click the Assets folder.

  5. Create a new Folder and call it Prefabs.

  6. Make Player a prefab by dragging it to Prefabs folder you just created.

  7. 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.

  8. Select NetworkManager.

  9. Inside the NetworkManager component tab, locate the NetworkPrefabs field.

  10. Click + to create a slot.

  11. Drag this player prefab from above into the new empty slot


    When you select the Default Player Prefab , you are telling the library that when a client connects to the game, automatically spawn this prefab as the character for the connecting client. If you do not have any prefab set as Default Player 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.

  12. Create a 3D Object->Plane, centered at (0,0,0).

  13. Save your scene

Testing Hello World#

Now we will test to see if everything works as expected.

  1. Click Play.
  2. 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"

Special Thanks

This guide would not have been possible without the hard work and support of Fernando Cortez, Unity.