Skip to content

hathora/photon-fusion-br

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hathora Cloud + Photon Fusion BR Sample Game

UnityVersion HathoraSdkVersion

This sample game was started from Photon's Fusion Battle Royale Sample

Overview

The original Photon Fusion BR200 was a AAA and production-ready third-person battle royale shooter game sample. We have added integration to deploy a Photon Fusion dedicated server on Hathora Cloud. By deploying your Photon Fusion game on Hathora Cloud you unlock all the benefits of dedicated servers (cheat protection, improved latency, more stable connections), while also gaining access to 10+ global regions that map nicely with Photon Cloud's regions.

  • Hathora SDK
  • Hathora high-level wrappers
  • HathoraServerConfig build, deployment and room management utils

Check it out to learn more about hosting Photon Fusion on Hathora Cloud and accessing the Hathora SDK. We have made a few modifications to make this game easily deployable with a dedicated server on Hathora Cloud.


Readme Contents and Quick Links

Click to expand/collapse contents


Getting the project

Direct download

  • select Code and select the 'Download Zip' option. Please note that this will download the branch you're currently viewing on Github

Requirements

  • This sample game is compatible with the latest Unity Long Term Support (LTS) editor version, currently 2021 LTS. Please include Linux Dedicated Server Build Support in your installation, as well as Linux Build Support (Mono).

  • Photon account with an active app created (for App Id Fusion).

  • Hathora Cloud account with an active app created (for AppId).

Steps

  1. If building your Linux headless server via HathoraServerConfig, the Dockerfile will automatically add the -args necessary to start "as a server

  2. Use the Hathora Unity plugin to configure, build, and deploy your server on Hathora Cloud via Assets/Hathora/HathoraServerConfig. See Hathora Unity Plugin

    • After setting up, serialize @ Menu scene's HathoraManager GameObject's HathoraServerConfig.
    • At the same spot, also serialize HathoraClientConfig next to the same file.
  3. Once deployed, create a room in Hathora Cloud via any method:

  • Create via Menu scene (as a Client): Click "Create" button at the bottom-right (adds a browsable Lobby)
  • via Hathora ServerConfig: Click "Create Room" button in the "Create Room" dropdown group
  • via Hathora Console in your browser at the top-right
  1. Play the Menu scene and join the new Room that appeared in a browsable Lobby list.

Altered Photon Files

Within this repro, we have already made changes to support Hathora. However, if you are interested in the core changes, in order of importance:

  1. Asssets/TPSBR/Scripts/Networking/Networking.cs

    • At ConnectPeerCoroutine(), if Server GameMode: Get Hathora Cloud Proccess/Room info to set Photon startGameArgs. Server name, max # of players, etc.
  2. Assets/HathoraPhoton/HathoraMatchmaking.cs

    • We override Photon's Matchmaking.cs to check if the user created a new Lobby from the Menu scene. Pure Photon will have the user be both a Client and Server. In Hathora, we want to create a dedicated server in the cloud (rather than have the player host as a server).
  3. Assets/TPSBR/Scenes/Menu.unity

    • Added HathoraManager GameObject with manager scripts.
      • (!) Serialize your selected HathoraServerConfig & HathoraClientConfig files here!
      • Added HathoraCreateDoneTxt & HathoraCCreateStatusTxt for status texts.
      • Renamed Matchmaking prefab to HathoraMatchmaking -> Swapped Matchmaking.cs with HathoraMatchmaking.cs.
        • When the users clicks "Create": instead of locally hosting as a server, we'll create a Hathora Cloud dedicated server (Room with Lobby) and show the Lobby list.

Region Mapping

Within the demo, we have included HathoraRegionMap.cs to map the following Photon<>Hathora regions:

<< Photon : Hathora >>

  • "us" : Washingington DC
  • "usw" : Seattle
  • "asia" : Singapore210
  • "jp" : Tokyo
  • "eu" : Frankfurt
  • "sa" : SaoPaulo
  • "kr" : Singapore

Default Dockerfile launch argss

  • -batchmode | Unity arg to run as headlesss server
  • -nographics | Unity arg to skips shaders/GUI; requires -batchmode
  • -dedicatedServer | Photon arg to automatically start as dedicated server
  • -deathmatch | Photon arg to automatically start deathmatch game mode
  • -maxPlayers 5 | Photon arg
  • -scene GenArea2 | Photon arg
  • -region us | Photon arg; see Photon<>Hathora mapping in the section below
  • -serverName hathoraDeployedServer | Shows up in the lobby List under name
  • -sessionName hathoraDeployedServerSession | Photon arg; unknown use (arbitrary?)
  • -port 7777 | The default and recommended Docker container port
  • -mode server | Hathora arg to start as Server when using a HathoraArgHandler script; unnecessary in Photon.

Troubleshooting

Bugs

  • Report bugs in the sample game using Github issues

Documentation



Community

For help, questions, advice, or discussions about Hathora Cloud and its samples, please join our Discord Community. We have a growing community of multiplayer developers and our team is very responsive.

Other samples

Hathora Unity Plugin

Hathora Unity Plugin (with FishNet and Mirror demos) is our Unity Plugin that comes with FishNet and Mirror networking demos. It allows you to deploy your game on Hathora Cloud directly from our editor plugin.

Unity NGO Sample

@hathora/unity-ngo-sample takes Unity's 2D Space Shooter sample game with Unity NetCode for Game Objects (NGO) and modifies it to be easily deployable on Hathora Cloud.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published