How to Add Dedicated Servers to Unity's NGO Boss Room Sample with Edgegap's Fork

This tutorial covers how to add dedicated servers to Unity's NGO Boss Room sample using Edgegap's fork, so you can host your multiplayer game on servers spun up on demand, in a region close to your players, worldwide. The base Unity sample only runs peer-to-peer, through Lobbies; this fork comes ready to run as a dedicated server, with Edgegap's Unity plugin already integrated.

We also recommend following our documentation.

Part 1 - Setup & Installation

Before opening anything in Unity, we need to clone the project. That requires Git and Git LFS. Git LFS is what pulls the sample's large art assets, and cloning without it leaves you with an empty project. On macOS, we install both through Homebrew.

Install the prerequisites for your operating system:

macOS

brew install git-lfs
git lfs install
brew install git-lfs
git lfs install
brew install git-lfs
git lfs install

Linux (Debian/Ubuntu-based)

sudo apt update
sudo apt install git git-lfs -y
git lfs install
sudo apt update
sudo apt install git git-lfs -y
git lfs install
sudo apt update
sudo apt install git git-lfs -y
git lfs install

Windows (PowerShell)

winget install --id Git.Git -e
winget install --id GitHub.GitLFS -e
git lfs install
winget install --id Git.Git -e
winget install --id GitHub.GitLFS -e
git lfs install
winget install --id Git.Git -e
winget install --id GitHub.GitLFS -e
git lfs install

Confirm the tools are installed:

git --version
git lfs version
git --version
git lfs version
git --version
git lfs version

Now clone the project. We keep it in a short, tidy folder. The git clone command is the same on every OS; only the folder syntax differs. Git names the cloned folder after the repository, so we rename it to bossroom afterward.

macOS / Linux

mkdir -p ~/unity-ngo
cd ~/unity-ngo
git clone https://github.com/edgegap/netcode-sample-unity-ngo-bossroom.git
mv netcode-sample-unity-ngo-bossroom bossroom
mkdir -p ~/unity-ngo
cd ~/unity-ngo
git clone https://github.com/edgegap/netcode-sample-unity-ngo-bossroom.git
mv netcode-sample-unity-ngo-bossroom bossroom
mkdir -p ~/unity-ngo
cd ~/unity-ngo
git clone https://github.com/edgegap/netcode-sample-unity-ngo-bossroom.git
mv netcode-sample-unity-ngo-bossroom bossroom

Windows (PowerShell)

mkdir unity-ngo
cd unity-ngo
git clone https://github.com/edgegap/netcode-sample-unity-ngo-bossroom.git
Rename-Item netcode-sample-unity-ngo-bossroom bossroom
mkdir unity-ngo
cd unity-ngo
git clone https://github.com/edgegap/netcode-sample-unity-ngo-bossroom.git
Rename-Item netcode-sample-unity-ngo-bossroom bossroom
mkdir unity-ngo
cd unity-ngo
git clone https://github.com/edgegap/netcode-sample-unity-ngo-bossroom.git
Rename-Item netcode-sample-unity-ngo-bossroom bossroom

To confirm the assets pulled correctly, check the size of the Assets folder. It should read in the hundreds of megabytes. If it reads zero, Git LFS did not pull the real files, so revisit the install step above before continuing.

With the project cloned, open it in Unity in the exact editor version the fork was built with:

  1. Open Unity Hub and select "Add", then "Add project from disk".

  2. Locate and select the "bossroom" folder you just cloned.

Unity Hub flags that the project needs a specific editor version. As of writing, this fork is pinned to Unity 6000.0.54f1. Install that exact version rather than the latest LTS, since a newer version is likely to break parts of the sample. When installing the editor, include the Linux server dependencies: "Linux Build Support" (including Mono and IL2CPP) and "Linux Dedicated Server Build Support".

Open the project. On this first open, Unity likely drops into Safe Mode. This is expected and does not need repairing: a fresh clone is missing a Unity Gaming Services package the sample's matchmaking client depends on, which we add now.

  1. From the top navigation bar, select "Window", then "Package Manager".

  2. Set the package source to "Unity Registry".

  3. Search for "Multiplayer Services" and select "Install".

This package resolves the missing references and takes the project out of Safe Mode. Confirm the Console shows zero compile errors before moving on; a clean compile is the gate for everything that follows.

Your sample is now installed and opening on the pinned Unity version.

Part 2 - Edgegap: Game Server Hosting & Orchestration

To add a dedicated game server to your project, open Edgegap's Unity plugin for game server hosting. It is already integrated into this fork. If it is not present in your own project, add it through Unity's Package Manager using the link in our documentation.

The first step is to add a token:

  1. Select "Get Token". A browser window opens.

  2. Sign in to the platform using your preferred SSO method. You may need to create an organization; once complete, your token appears automatically. Copy it.

  3. Back in the plugin, paste the token and select "Validate Token".

The rest of the plugin's options now open up.

First, confirm you have the Linux Server dependencies installed, which we installed with the editor in Part 1.

Next, set Linux as your build target:

  1. Select "Edit Settings" to open Unity's Build Settings.

  2. Switch the platform to "Linux Server".

  3. Confirm your game scenes are included and in the right order. Here, the list starts with "Startup", followed by the "MainMenu" scene, and then the gameplay scenes.

Back in the plugin, build your server with the "Build Server" button. After a few seconds, the build compiles successfully.

Under "Containerize your Server", make sure Docker is running by selecting "Validate". If you do not have Docker installed, install Docker Desktop first; it is the standard tool for containerizing game servers and other applications. We skip the optional parameters for this tutorial; details on their use are in our documentation. Select "Containerize with Docker". After a short period, containerization is successful.

You could now test your game server locally, but here we go straight to testing online. Upload the containerized server to Edgegap's platform:

  1. Make sure the correct application is selected, then select "Upload Image and Create App Version". After a few seconds, a browser opens to the platform.

  2. The "Create Version" page is prefilled. You can configure optional settings, including vCPU resource usage, memory, and more, but we create a new version with default settings. Scroll down and select "Submit".

  3. The "Create Port" pop-up opens. Confirm your netcode's default port and protocol type. Note that this port is UDP on 7777 for this sample. This may be different with other netcodes. As such, make sure to review your netcode's documentation for the accurate port to your use case. Select "Submit".

Finally, deploy the server you just containerized:

  1. Back in Unity, select the correct application and its version from the list.

  2. Select "Deploy to Cloud". This automatically deploys the game server to Edgegap's platform.

After a few seconds of loading, your game server is ready and online.

Part 3 - Testing

Let's test the deployment. Start by selecting the deployment to open its detail page. This page includes a range of information about your running server.

To connect, scroll down and copy the Host IP, and take note of the external port, for example 32699 in our case.

Then, launch your game scene and select "Join with IP". Paste your IP address and input your external port. Ignore any development warnings, select your character, and launch the game. It automatically connects to your game server hosted on Edgegap's network.

Congratulations, you are now playing the Boss Room sample from Unity, modified by Edgegap to run on dedicated servers, online.

Part 4 - Next Steps

That is all for adding dedicated servers to Unity's Boss Room sample, which gives you a ready-to-run Netcode for GameObjects project hosted on Edgegap, deployed on demand worldwide.

While playing solo is fine, you will likely want to play and test online with two players. "Join with IP" is a valid method, but we recommend setting up a matchmaker instead. We have a tutorial for deploying dedicated servers from Unity's UGS Matchmaker using this same Boss Room sample, as well as a tutorial for Edgegap's own free, fully managed matchmaker.

If you have any questions, join our Discord.

Get your Game Online Easily & in Minutes

Start Integrating Now!

Get your Game Online Easily
& in Minutes