Edgegap Plugin - Automated Game Server Hosting - Unity Tutorial

Hi,

In this video, we will cover how to easily set up any Unity project to deploy, and host, dedicated game server directly from Unity’s editor using the Edgegap plugin.

As to get your game online and playable, worldwide, in seconds.

Let’s get to it.

Chapter 1: Requirements

Before using the plugin, there are three requirements to ensure Unity works for dedicated servers.

First, make sure you use the latest Edgegap plugin.

While Edgegap is available in the Unity asset store, a far easier way to add and keep Edgegap up to date directly from Unity’s editor through the “Git” method.

From the Unity editor, select "Window", then "Package Manager". Click on the "+" button and select "Add Package from git URL". Then, type the GIT URL, namely "https://github.com/edgegap/edgegap-unity-plugin.git", which is available in full in this video’s description or GitHub itself.

Finally, click "Add", and the package will automatically download and be added to your project!

Second, head over to Unity’s Hub to confirm you have installed all three “Linux Dedicated Server Build Support” module in your project. If not, simply click on the package and install it.

The third and final prerequisite is to install and run Docker. It containerizes your game servers to help it deploy and run faster. Installing Docker is easy and takes minutes, simply head over to Docker dot com and follow the installation procedure.

Now, let’s get started!

Chapter 2: Edgegap’s Unity Plugin

Load up your project. In our case, we are using the tank sample project from Mirror Networking that is already setup for dedicated game servers. Any project set up for dedicated server will work with Edgegap’s plugin.

From the top navigation menu, select “Tool” and then click on “Edgegap Server Hosting” which opens the plugin’s window.

To function, you first must generate a token.

To do so, all you need is an Edgegap account. Click on the “Sign in to Edgegap” button which will open up your browser.

If you do not have an account, signing up is free and takes just a few seconds. Select “Get Started” at the bottom, then input your email and a password and opt in to 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 “Validate Token”. If the token is valid, the “Build Your Server” tab opens automatically.

First, you can validate if the Linux dependencies are functional.

For established projects, make sure to edit the Unity build settings to support dedicated servers.

Optionally, change your Build Folder Name.

Then, select “build your server”. 

Once the server build process is successful, move to the third step – containerizing your game server.

First, check that Docker is running.

Then, every field here is already populated. For power users, they can be used to tweak build path, image name, image tags and path of dockerfile. For most, including this initial tutorial video, we’ll keep the default. 

Let’s go. Select “Containerize with Docker".

After a few minutes, your containerization should be successful.

Let’s deploy locally, namely on your machine, to make sure the server image is functioning properly before we upload and deploy. Make sure to read our documentation to learn more about these details.

We’ll skip it for this video.

However, make sure to take note of the port number, namely here it is seven, seven, seven, seven, and the protocol type – in this case UDP, for later.

Now, it is time to get your server online to our platform’s container registry and make your game playable worldwide.

Application name, server image name and tag provide more customization options, but we’ll keep them to default here again.

Click on “Upload image and create app version” and after a few seconds, a browser to the platform opens up. You can once again configure optional settings, including vCPU resource usage, memory and more, but we’ll create a new version with defaults settings.

You will now be prompted to define a Port for your new Application version. Make sure to set the same server port value from the “Test Your Server Locally” step. Click “submit”.

We’ll deploy the server directly from the platform. While you can deploy the server from the web platform, return to the plugin to deploy it from Unity.

Under the “Deploy a Server to Edgegap” section, while application name is filled automatically, select the version from the platform you want to deploy. Click on “Deploy to Cloud”, and after a few seconds of waiting, your game server is now available for the world to play.

Congratulations!

Chapter 3: Testing

Evidently, test things in your projects.

Mirror sample has its own simple test, and each project is likely unique. In our case, select the deployment from the platform, and copy the host’s URL and note the external port. Then, in the engine, close the plugin’s window and start the project. Once running, replace the client’s address with the host’s URL and change to the external port from the deployment. Finally, launch the server, and it connects to the deploy easily.

Once you are done testing, return to the Edgegap plugin to automatically stop the server instance by selecting “Stop Server”.

Conclusion

That is all for the Edgegap plugin for Unity, 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.

Thanks for watching!