Fusion Simple FPS integration
View source code on GitHub:
fusion-simple-fps-hathora
The Simple FPS project demonstrates how to create a fully functional multiplayer game using Photon Fusion 2 and Hathora server orchestration.
This project is focused on setting up server hosting for Simple FPS, for initial setup see Photon's Simple FPS docs.
Before continuing, review these requirements:
- You must create a Photon account and a Photon Fusion 2 Application Id.
- You must create a Hathora account.
- You must use Unity Editor 2022.3.
Note: Photon Fusion SDK is a third-party dependency and is subject to Exit Games' license terms.
Project setup
Installing the Unity Editor
To work with the Fusion Simple FPS project, you must use Unity Editor 2022.3 LTS. See Installing Unity to learn how to install the Unity Editor for your operating system.
Required components:
- Linux Build Support (IL2CPP)
- Linux Dedicated Server Build Support
Note: When installing the Unity Editor, select both components from the components list. Otherwise, you won’t be able to build the standalone Linux binary.
Get started with Photon Fusion 2
If you don’t already have one, you’ll need to create a Photon account to start using Photon Fusion. After you have an account, log into the Photon Dashboard and create a new Fusion 2 application.
Note: See the Photon Fusion Introduction if you have trouble getting started.
- From the Photon Dashboard, select Create a new app.
- Set Photon SDK to Fusion.
- Set SDK Version to Fusion 2.
- Name the application.
- Optionally, provide a brief description and URL.
- Select Create.
- After creating the application, select App ID in the Photon Dashboard and copy it.
Linking the Photon Fusion 2 project
Download the Fusion Simple FPS, then launch it in the Unity Editor.
- Select Tools > Fusion > Fusion Hub.
- Paste the App ID you copied into the Fusion App Id field and confirm by Enter.
Get started with Hathora Cloud
Simple FPS dedicated servers can be deployed globally on Hathora Cloud. With Hathora Cloud, you get some key benefits:
- Automated scalability and server orchestration
- Immediate access to 12 global regions (map nicely with Photon Cloud regions)
- Simple integration process
- Configure, build, and deploy directly from Hathora’s Unity editor plugin
Relevant files for Hathora integration can be found:
- Assets/Hathora
- This is the installed Hathora Unity plugin.
- Assets/Photon/FusionAddons/Hathora
- Contains Hathora + Fusion game independent integration.
- Assets/Scripts/Hathora
- Contains integration files specific to Simple FPS.
To enable integration:
- Create a Hathora Cloud account at https://console.hathora.dev
- Select the HathoraServerConfig asset included in the project (Assets/Photon/FusionAddons/Hathora/Configs).
- Log in with your Hathora Cloud account - this will open a web browser window to complete login.
- Create a new application.
- Now in the Unity plugin, you can:
- Refresh your application list (1)
- Select your new application (2)
- Copy the App Id (3)
- Select the HathoraClientConfig asset included in the project (Assets/Photon/FusionAddons/Hathora/Configs) and update the App Id.
- Select HathoraServerConfig and Generate Server Build.
Note: Sometimes the build fails due to platform switching or loading Linux platform toolchain packages in the background. To resolve it, try restarting the Unity editor, switch to the Dedicated Server - Linux platform and start the build manually. Make sure the output path matches Build directory and Build file name, in this case [PROJECT_ROOT]/Build-Server/Hathora-Unity_LinuxServer.x86_64
- Deploy server build to Hathora Cloud.
- Now you should see the Latest deployment being updated in Hathora Cloud
Building & starting the game client
Creating a client build is no different from creating any other regular build.
- Select your target platform and make a build.
- When the build is done, run two instances of the build.
- Press Quick Play on one client and wait until the game is loaded. It can take a while if you are running for the first time.
- Press Quick Play on the second client and it should connect you into the same room.
- Check Hathora Cloud, you’ll be able to see server instance details.
- Congratulations, you’ve just finished basic integration and are ready to iterate your own game!
A1: Multi-peer mode
Fusion supports running multiple server instances within a single process, called multi-peer mode. This feature allows for efficient CPU utilization and reduces overall cost.
- Make sure the Peer Mode is set to Multiple in NetworkProjectConfig asset (Assets/Photon/Fusion/Resources).
- Configure your application Settings in Hathora Cloud:
- Set the Number of rooms per process to 3.
- Add transport configurations and set Port and Name properties. Make sure it is configured exactly the same as in the following image.
- Select HathoraServerConfig in the Unity editor.
- Generate a new Linux dedicated server build (check sections above for more details).
- Configure the config as in the following image and deploy.
- After joining with enough clients, you’ll be able to see on Hathora Cloud multiple rooms / games running within a single process.
A2: References
This guide covers basic configuration and operation of Simple FPS on Hathora. We recommend to explore following topics which are related:
- Simple FPS documentation - provides general information about Fusion Simple FPS project and its architecture overview.
- Simple KCC documentation - provides more information about Fusion Simple Kinematic Character Controller addon used in Simple FPS and its configuration.
- Hathora documentation - provides more information about Hathora Cloud configuration and additional topics not covered by this guide:
- Containerization with Docker files.
- Integration logic walk-through.
- Troubleshooting tips.