
Add Dedicated Game Server to Photon Fusion 2 through the Asteroids Sample - Learn How to Host a Multiplayer
In this video, we will cover every step on how to easily deploy a game server to host Photon Fusion 2’s Asteroids multiplayer sample for two players in Unity Engine. Using Edgegap’s own Fusion 2 Asteroids sample and its game server hosting platform.
Let’s get started
Part 1 - Setup
Alongside this video, we recommend following our documentation, a link is available in the description and the comments.
First, use the link to download Edgegap’s modified Fusion 2’s Asteroids sample. Select “Code” and download the “.zip” file. Then, unzip the file on your computer.
Starting from an all-new project from Unity’s HUB, select "Install Editor" and select the “Unity 6 LTS” version. As of recording, Unity 6.0 is the “long term release” or LTS. Newer version may have incremental improvements but are very likely to break certain functionalities. As such, we strongly recommend using LTS version to ensure that compatibility works on this sample, and your development project.
Now, back to the projects menu, select “Add” and then “Add from Disk”. Locate the sample and select its main folder.
Here, Unity is likely going to warn you about a missing Unity version. As previously stated, the latest LTS as of recording is “6000.0.56.f1”. Ignore this warning, and select the latest LTS version. While you can use the latest recommended version, be aware it could break the project.
Part 2 - Edgegap: Game Server Hosting & Orchestration
The next step is to deploy a game server to have players connect to the host and play online.
Edgegap is a game server orchestration platform tailored for multiplayer games that helps you host your multiplayer easily.
First, create a free Edgegap account.
Either head to "Edgegap.com" and select "Start for Free” or use the direct link in the documentation. 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.
Edgegap has automated the process of creating an app version using Photon Fusion 2’s Asteroids sample. While you can create a version manually, simply head over to our documentation and select the "Create a new app version for your application" link, which is also available in the description and comments.
The "Create an Application" prompt is now pre-filled. Select "Create an Application". Then select the "Fusion 2 Asteroids Unity" button which automatically fills the application's metadata.
Then, scroll down and select "Submit".
With your application created, the next step is to create a deployment which is the game server players will connect to.
Return to Unity’s editor, close the welcome message, and from the top navigation bar, select “Tools”, then “Edgegap Hosting”.
Automatically, the plugin connects itself to your Edgegap account. If not, select “Get a Token” to create one in the platform.
Steps two to six, thanks to the sample, are already pre-filled. Scroll down to the “Deploy a Server on Edgegap” section and select “Deploy to Cloud” button.
After a few seconds, a new window in your web browser appears.
Click on the deployment to open its detail page, which highlights where the game server was deployed. Which can be useful for troubleshooting Fusion 2.
Please make sure to note the URL to which players must connect to, copying it, under the "Host" section. It is also important to note the External Port for testing.
Part 3 - Testing
To test out multiplayer game, first open Fusion 2’s sample, and filter the assets to “scenes”.
Then, double-click on the scene named “AsteroidsSimple-Menu.unity”.
Now, paste the host’s URL copied from the deployment in the “Room Name” input field. Start the deployment by selecting the “Start Edgegap” button.
Certain users may get an error as Photon requires its “rooms” to be connecting to the Photon Cloud region where the deployment is located. If you do, reopen “Fusion” from the “Tool” tab from the top menu and select “Realtime Settings”.
In the inspector tab, open “App Settings” and under “Fixed Region” you will need to input the region your deployment was made from. Which must match Photon’s list from their documentation as shown on screen. In this example, the code from the right column is “asia”. Make sur to save. You can cross reference from the platform’s deployment location.
Return to the editor and start the sample by clicking on the “play” button.
Now, select “Start Edgegap” which connects the game to your previously deployed game servers.
Congratulations, you've deployed your first game server!
Online multiplayer requires more than one player though!
To simulate this, you need the "Multiplayer Play Mode" package or “Parrel Sync”.
As we have multiple videos which showcases how use Unity’s “Multiplayer Play Mode”, see above for direct links, we will use “Parrel Sync” in this video.
Install ParrelSync through its Git’s URL. Once installed, it will appear in the top navigation bar.
Select “ParrelSync”, then “Clones Manager” and finally “Create a New Clone”.
After some loading time, select “Open in New Editor”.
Now, an entirely new project, cloned from the initial one, opens up. This allows you to simulate a second player.
We'll move each window to make things easier to see, but this is purely optional.
The second to last step is to start the game scene in Unity.
Then select “Start Edgegap” within both windows, and as you can see, both players appear.
Congratulations, you are now using Photon Fusion 2’s Asteroids demo to play multiplayer online using Edgegap's game server hosting platform.
Part 3 - Next Steps
Edgegap’s Photon Fusion 2 sample is a useful tool to learn multiplayer in Photon.
The next step in your development journey will be to add a matchmaker, whose tutorial is linked here.
