Fish-Networking Plugin - Automated Game Server Hosting - Unity Tutorial
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!
Chapter 1: Requirements
There are three requirements to ensure everything works.
First, make sure you use the latest Fish-Networking plugin; at least v3 and up. It can be downloaded directly from the Unity asset store or on GitHub. A direct link is in the description.
Once installed and imported Fish-Net from the store, access it by selecting “Window” from the top menu, then select “Package Manager.”
From the drop-down menu select “My Assets” to find the Fish-Net plugin.
For new users, we strongly recommend watching the amazing community tutorials to use Fish-Net to its full capabilities.
Second, within Unity, head over to Unity’s Hub to confirm you have installed the “Linux Dedicated Server Build Support” module in your project. If not, simply click on the package and install it. Make sure to restart Unity to avoid problems.
The third and final prerequisite is to install and run Docker. It containerizes your game servers to help it deploy and run faster. If you haven’t yet, you can go watch our Docker installation video, or head over to Docket dot com and follow the installation procedure. It’s easy and takes just a few minutes.
Chapter 2: Fish-Networking
Now, let’s get started in Unity!
From the editor, let’s open one of Fish-Net’s sample project – in our example, we will use the Hash Grid demo, which is set up for dedicated game servers.
Once opened, select the “Network Manager” game object in the scene, and in the component inspector, confirm that two configurations, namely “Run in Background”, and “Don’t Destroy On Load” are enabled.
Below, under the “Tugboat” section, note the “Network Address” should be currently set to “Local Host”. This will be swapped to the hosting address later after the Edgegap game server is deployed. Similarly, the “Port” value is likely set to a default, internal state such as 7112 in this case, which will have to be updated.
If the “Tugboat” section is missing, select “Add Component” and type in Tugboat. It will appear under search.
Chapter 3: Edgegap
From the top navigation menu, select “Tool” and then click on “Edgegap Hosting”, which will open the plugin’s window.
If Edgegap isn’t available, even if its packaged as part of Fish-Networking 3.0 onwards, the latest version of the plugin can be downloaded directly from our GitHub page.
At this point, if you see an “Error 400” warning, it means you are either missing or have an outdated version of Newtonsoft. Go to “Window”, then select “Package Manager”. Select the plus sign, and chose “Add package by name”. Paste the Newtonsoft package name, which you can find in this YouTube video’s description.
To function, you first have to generate a token.
To do so, you must create an Edgegap account. Click on the “Get a Token” button which will open up your browser.
Signing up is free and takes just a few seconds. First, select “Get Started” at the bottom, then from the login screen, input your email and a password and opt into our terms. You’ll then instantly get a verification email. Click on “Confirm Your Email” to validate your account. Finally, input your organization’s name and confirm.
This is Edgegap application’s dashboard. We strongly recommend exploring it with the tour, but we’ll skip it for this video. Automatically, a pop up with your unique OneClick Token appears. Simply copy it by clicking on the clipboard icon and paste it directly in the plugin’s text box.
Then, select verify which confirms the token is valid. The “Application Info” tab now opens automatically.
Should you already have an application on our platform, input its name in the text box and load it as an existing app. If not, which is the case in this tutorial, simply enter your project’s name. It must be in lowercase, with no spaces.
The “Create Application” button is now enabled. Select it. This opens the “Container Registry” and the “Deployment” tabs.
Container registry is where your game server’s container is stored. All you need to do is make sure the port and protocol types are accurate to your netcode transport’s as to ensure the server adequately listens for connection.
This information can be found in the network manager’s inspector tab. Here is Fish-net's sample project port, found under the “Tugboat” Transport from earlier in the video.
Here, the protocol type is accurate as this sample project by Fish-net uses UDP.
If you are unsure which protocol type to use, refer to your netcode’s documentation to confirm which transport it uses, or select the appropriate option based on your unique choice.
“New Version Tag” refers to the unique version of your server. This field requires your manual input. We recommend changing the value whenever you proceed with updates to your game server.
For advanced users, Edgegap provides the option to use a “Custom Container Registry”. For this tutorial, we will use the Edgegap’s default one.
Next, select “Build and Push”. This automatically compiles the project into a dedicated Linux server, then create a Docker container which is deployed to Edgegap’s registry.
Then, create a new deployment. Under “Status”, you will see its progress. Once ready, an URL appears. Copy it by clicking the clipboard button, then under the “Tugboat” component, replace the current “Client Address” by pasting the URL, and remove the port and colon.
Replace the port with the new port from Edgegap’s URL.
In the editor on the left under “Network Manager”, select “network HUD Canvas” and under the “Script” section, make sure the “Auto Start Type” option is set to “Disabled”.
Finally, start your game scene by clicking the play button atop the editor.
Congrats, your game is now online for the world to play!
Chapter 4: Testing
Evidently, test things first.
In the game scene, select “Client” to test if your deployment works with the game server hosted by Edgegap.
Once you are done testing, return to the Edgegap plugin to stop the server instance by selecting “Stop Server”.
Remember that, if you’re looking to make a new game server build, you’ll have to change back the Client Address, Port and Auto Start Type to the relevant information for the game server.
That is all for the Edgegap plugin with Fish-Networking netcode, which empower game developers with automated game server and simple hosting.
The likely next step in your game development will be to connect players. For more information on Edgegap’s free, simple and fully automated matchmaker, you can check out our tutorial.
Or join Edgegap’s Discord community to develop and share with game devs just like you.
Thanks for watching!