Skip to main content

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.

Required Unity modules

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.

  1. From the Photon Dashboard, select Create a new app.
create photon app
  1. Set Photon SDK to Fusion.
photon configuration
  1. Set SDK Version to Fusion 2.
  2. Name the application.
  3. Optionally, provide a brief description and URL.
  4. Select Create.
  5. After creating the application, select App ID in the Photon Dashboard and copy it.
copy photon app id

Linking the Photon Fusion 2 project

Download the Fusion Simple FPS, then launch it in the Unity Editor.

  1. Select Tools > Fusion > Fusion Hub.
select fusion hub
  1. Paste the App ID you copied into the Fusion App Id field and confirm by Enter.
paste photon app id

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
  • Assets/Photon/FusionAddons/Hathora
    • Contains Hathora + Fusion game independent integration.
  • Assets/Scripts/Hathora
    • Contains integration files specific to Simple FPS.

To enable integration:

  1. Create a Hathora Cloud account at https://console.hathora.dev
create Hathora account
  1. Select the HathoraServerConfig asset included in the project (Assets/Photon/FusionAddons/Hathora/Configs).
  2. Log in with your Hathora Cloud account - this will open a web browser window to complete login.

https://lh7-us.googleusercontent.com/mvCu7wjIUrBxZlJctpcmdDOZ92_VqEQz1yLZv7QQjX_MNo5cUO7eIDbTHE2SmX_nTev4vwdq_PNk9IrWHp9xFeL6q45dbbkBY9mRznCYNNS1oaHWnOcT8TivUeDGtzyYlFy6BTdUw-kN5OtLBEsLZwU

  1. Create a new application.
create Hathora application create Hathora app part 2
  1. Now in the Unity plugin, you can:
  • Refresh your application list (1)
  • Select your new application (2)
  • Copy the App Id (3)
select appId in Hathora plugin
  1. Select the HathoraClientConfig asset included in the project (Assets/Photon/FusionAddons/Hathora/Configs) and update the App Id.
add appId to HathoraClientConfig
  1. Select HathoraServerConfig and Generate Server Build.
generate server build via plugin

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

manual server build debug
  1. Deploy server build to Hathora Cloud.
deploy build via plguin
  1. Now you should see the Latest deployment being updated in Hathora Cloud
view latest deployment in Hathora Console

Building & starting the game client

Creating a client build is no different from creating any other regular build.

  1. Select your target platform and make a build.
  2. When the build is done, run two instances of the build.
  3. 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.
starting game client
  1. Press Quick Play on the second client and it should connect you into the same room.
  2. Check Hathora Cloud, you’ll be able to see server instance details.
View server spinning up in Hathora Console
  1. 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.

  1. Make sure the Peer Mode is set to Multiple in NetworkProjectConfig asset (Assets/Photon/Fusion/Resources).
cofnig peer mode
  1. Configure your application Settings in Hathora Cloud:
  2. Set the Number of rooms per process to 3.
  3. Add transport configurations and set Port and Name properties. Make sure it is configured exactly the same as in the following image.
Configure Hathora advanced deployment settings
  1. Select HathoraServerConfig in the Unity editor.
  2. Generate a new Linux dedicated server build (check sections above for more details).
  3. Configure the config as in the following image and deploy.
Update Hathora plugin deploy settings
  1. After joining with enough clients, you’ll be able to see on Hathora Cloud multiple rooms / games running within a single process.
View Hathora process with multiple rooms/matches running

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.
Join our developer community!