Discover how Edgegap works

Discover how Edgegap works

Fish-Networking Plugin - Automated Game Server Hosting - Unity Tutorial

Published

Published

Published

Last reviewed for accuracy

Last reviewed for accuracy

Last reviewed for accuracy

We will cover every steps to set up Fish-Networking’s free and open source netcode in combination with hosting with Edgegap for your project to deploy, and host, an automated game server directly from Unity’s editor. As to get your game online and playable, worldwide, easily, and in minutes.

Let’s get started!

Part 1 - Setup

Two things need to be in place so Unity can build and containerize a dedicated server.

First, install and run Docker Desktop. It containerizes your game servers so they deploy and run faster, and is used by millions of developers and the world's largest companies.

Second, install all three Linux build modules if you haven't already. In Unity Hub, open Installs, then Manage on your project's Unity version. Scroll down and make sure the Linux Build Support modules for both IL2CPP and Mono, along with the Linux Dedicated Server Build Support module, are installed.

Disclaimer

Make sure to add Edgegap's Unity plugin using the "Add project from Git" to ensure you use the latest version of the project.

  1. Select "Window" then "Package Manager"

  2. Click on the "+" icon, then select "Add Project from Git"

  3. Paste Edgegap's Unity plugin URL: "https://github.com/edgegap/edgegap-unity-plugin.git"

  4. Select "Install"

2. Fish-Net Project Setup

Load up your Fish-Net project. The example here uses Fish-Networking's Hashgrid demo, which already ships set up for dedicated servers — any Fish-Net project configured for dedicated servers works the same way.

With the project imported and the demo scene open, inspect the NetworkManager. Under the NetworkManager section, make sure Run in Background and Don't Destroy on Load are enabled. Then find the Tugboat component in the Inspector; if it isn't there, add it as a component.

Set Port to 7777, Fish-Net's default port for connections (7112 is used for local testing). Review your netcode's documentation to confirm the right port for your own project.

Note the Client Address — here, localhost — since you'll change it during testing.

Finally, unfold the NetworkManager to the NetworkHudCanvas. Under Auto Start Type, select Server so the build you're about to create runs as a server.

3. Edgegap Unity Plugin for Dedicated Servers

Get Edgegap's latest Unity plugin for dedicated servers from its GitHub repo: github.com/edgegap/edgegap-unity-plugin. Select Code and copy the URL. Back in Unity, open Window → Package Manager, select the + button, choose Add package from git URL, paste the URL, and select Install. The package downloads and is added to your project automatically.

From the top menu, open Tools → Edgegap Hosting to bring up the plugin window.

The plugin first needs a token. Select Sign in to Edgegap to open your browser, then sign in or create an account with your preferred SSO — signing up is free and takes a few seconds. You may be prompted for your organization's name. From the dashboard, a pop-up provides your unique OneClick Token; copy it with the clipboard icon and paste it into the plugin's token field. Select Validate Token, and the Build Your Server tab opens.

Confirm your Linux server build requirements are installed. Select Edit Settings, then Open Scene List, to confirm the scenes you want in your server are selected — here, the Hashgrid Demo scene. The plugin switches the platform to Linux Server for you to ensure it builds a Linux server. Select Build Server (save your scene if prompted); the build completes after a few seconds.

Next, containerize. Confirm Docker is running with the Validate button. Default Docker parameters are fine for most projects, so select Containerize your Docker to start the process. It completes after a few minutes.

The plugin can also deploy locally to test on your own machine, but you can go straight to testing online. In the Upload to Edgegap section, select the correct application name and choose Upload Image and create app version. Your browser opens to the platform, where you can adjust optional settings such as vCPU and memory — defaults are fine to start. Scroll down and Submit. When prompted to define a port, set the same value as your transport (7777), choose the right protocol for your game (UDP here), name it something like gameport, and Submit.

Back in the plugin, open Deploy a Server to Edgegap, select the right application and version, and choose Deploy to Cloud. After a few seconds of loading, your game server is live and available worldwide.

Part 4 - Testing

Fish-Net's Hashgrid demo has its own simple test, and every project is unique — check how your own sample connects a client, as these exact steps may not map one-to-one to your project.

From the game server's detail page, copy the Host URL (your connection address) and note the External Port. Back in Unity, select the NetworkManager, find Tugboat's Client Address field, and paste the server's address. Enter the External Port in Tugboat's Port field. Then unfold the NetworkManager to the NetworkHudCanvas and, under Auto Start Type, select Client.

Start the project. Once it loads, it connects as a client to your deployed server. When you're done, return to the Edgegap plugin and select Stop Server to shut the instance down.

Part 4 - Next Steps

The natural next step is automatically starting and stopping servers and connecting players into matches. See Edgegap's free, fully automated matchmaker tutorial, and join the community on Discord.

Get your Game Online Easily & in Minutes

Start Integrating Now!

Get your Game Online Easily
& in Minutes