Boss Room is a fully functional co-op multiplayer RPG made with Unity Netcode. it's an educational sample designed to showcase typical netcode patterns often featured in similar multiplayer games.
Note: Boss Room is compatible with the latest Unity Long Term Support (LTS) Editor version (currently 2021 LTS). Make sure to include standalone support for Windows/Mac in your installation.
Boss Room has been developed and tested on the following platforms:
The minimum device specifications for Boss Room are:
- iPhone 6S
- Samsung Galaxy J2 Core
Contents and quick links
- Contents and quick links
- Boss Room Overview
- Getting the project
- Registering the project with Unity Gaming Services (UGS)
- Opening the project for the first time
- Exploring the project
- Testing multiplayer
- Index of resources
- Other samples
- Feedback form
Boss Room Overview
Boss Room is designed to be used in its entirety to help you explore the concepts and patterns behind a multiplayer game flow; such as character abilities, casting animations to hide latency, replicated objects, RPCs, and integration with the Relay, Lobby, and Authentication services.
You can use the project as a reference starting point for your own Unity game or use elements individually.
This repository also has a Utilities package containing reusable sample scripts. You can install it using the following manifest file entry:
For more information on the art in Boss Room, see ART_NOTES.md.
Getting the project
You can get the project by downloading it directly or cloning locally. However, if you use git, you must install Git LFS.
Installing Git LFS to clone locally
Boss Room uses Git Large Files Support (LFS) to handle all large assets required locally. See Git LFS installation options for Windows and Mac instructions. This step is only needed if cloning locally. You can also just download the project which will already include large files.
You can download the latest version of Boss Room from our Releases page. Doing so doesn't require you to use Git LFS.
Alternatively, you can click the green Code button, then select Download Zip. This downloadd the branch that you are currently viewing on Github.
Note for Windows users: Using Windows' built-in extraction tool may generate an
Error 0x80010135: Path too long error window which can invalidate the extraction process. A workaround for this is to shorten the zip file to a single character (for example, "
c.zip") and move it to the shortest path on your computer (most often right at
C:\) and retry. If that solution fails, another workaround is to extract the downloaded zip file using 7zip.
Registering the project with Unity Gaming Services (UGS)
Boss Room leverages several services from UGS to ease connectivity between players. To use these services inside your project, you must:
- Create an organization inside the Unity Dashboard.
- Enable the Relay service.
- Enable the Lobby service.
Opening the project for the first time
Once you have downloaded the project, follow the steps below to get up and running:
- Check that you have installed the most recent LTS editor version.
- Include standalone support for Windows/Mac in your Unity Editor installation.
- Add the project to the Unity Hub by selecting the Add button and pointing it to the root folder of the downloaded project.
- Unity imports all the project assets the first time you open the project, which takes longer than usual.
- Select the Play button. You can then host a new game or join an existing one using the in-game UI.
Exploring the project
Boss Room is an eight-player co-op RPG game experience, where players collaborate to fight imps, and then a boss. Players can select between character classes that were designed to provide educational oriented implementations of characteristics commonly found in similar small-scale netcode games. Control model is click-to-move, with skills triggered by a mouse button or hotkey.
One of the eight clients acts as the host/server. That client will use a compositional approach so that its entities have both server and client components.
- The game is server-authoritative, with latency-masking animations.
- Position updates are carried out through NetworkTransform that sync position and rotation.
- Code is organized in domain-based assemblies. See our ARCHITECTURE.md file for more details.
To see the multiplayer functionality in action, you can:
- Connect with a friend over your local area network
- Connect with a friend over the internet
- You can use UGS which helps remove the complexities of handling port forwarding
- Otherwise, the host will need to setup port forwarding on their router
See Testing multiplayer games locally for more information.
Local multiplayer setup
First, build an executable by selecting File > Build Settings > Build.
After you have the build, you can launch several instances of the build executable to host or join a game.
If you run several instances locally, you must use the Change Profile button to set different profiles for each instance for authentication purposes.
Note: If you’re using Mac to run multiple instances of the same app, you need to use the command line. Run
open -n BossRoom.app.
Multiplayer over Internet
Use the following instructions to test Boss Room with multiple players over the Internet.
First, build an executable and distribute it to all players.
Tip: it's possible to connect between multiple instances of the same executable OR between executables and the Unity Editor that you used to create the executable.
Next, you need to set up a relay. Running the Boss Room over the internet currently requires setting up a relay:
- Boss Room provides an integration with Unity Relay. You can find our Unity Relay setup guide here.
- Alternatively you can use Port Forwarding. The https://portforward.com/ site has guides on how to enable port forwarding on a huge number of routers.
- Boss Room uses
UDPand needs a
9998external port to be open.
- Make sure your host's address listens on 0.0.0.0 (127.0.0.1 is for local development only).
Index of resources
The Boss Room sample includes resources for gameplay, game flow, connectivity, Unity services, and other tools and utilities.
Boss Room includes the following gameplay resources:
- Action anticipation - AnticipateActionClient() in Assets/Scripts/Gameplay/Action/Action.cs
- Object spawning for long actions (archer arrow) - LaunchProjectile() in Assets/Scripts/Gameplay/Action/ConcreteActions/LaunchProjectileAction.cs
- Quick actions with RPCs (ex: mage bolt) - Assets/Scripts/Gameplay/Action/ConcreteActions/FXProjectileTargetedAction.cs
- Teleport - Assets/Scripts/Gameplay/Action/ConcreteActions/DashAttackAction.cs
- Client side input tracking before an action (archer AOE) - OnStartClient() in Assets/Scripts/Gameplay/Action/ConcreteActions/AOEAction.cs
- Time based action (charged shot) - Assets/Scripts/Gameplay/Action/ConcreteActions/ChargedLaunchProjectileAction.cs
- Object parenting to animation - Assets/Scripts/Gameplay/Action/ConcreteActions/PickUpAction.cs
- Physics object throwing (using NetworkRigidbody) - Assets/Scripts/Gameplay/Action/ConcreteActions/TossAction.cs
- NetworkAnimator usage - All actions, in particular Assets/Scripts/Gameplay/Action/ConcreteActions/ChargedShieldAction.cs
- NetworkTransform local space - Assets/Scripts/Gameplay/GameplayObjects/ServerDisplacerOnParentChange.cs
- Dynamic imp spawning with portals - Assets/Scripts/Gameplay/GameplayObjects/ServerWaveSpawner.cs
- In scene placed dynamic objects (imps) - Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetworkObjectSpawner.cs
- Static objects (non-destroyables like doors, switches, etc) - Assets/Scripts/Gameplay/GameplayObjects/SwitchedDoor.cs
- State tracking with breakables, switch, doors
- NetworkVariable with Enum - Assets/Scripts/Gameplay/GameState/NetworkPostGame.cs
- NetworkVariable with custom serialization (GUID) - Assets/Scripts/Infrastructure/NetworkGuid.cs
- NetworkVariable with fixed string - Assets/Scripts/Utils/NetworkNameState.cs
- NetworkList with custom serialization (LobbyPlayerState) - Assets/Scripts/Gameplay/GameState/NetworkCharSelection.cs
- Persistent player (over multiple scenes) - Assets/Scripts/Gameplay/GameplayObjects/PersistentPlayer.cs
- Character logic (including player's avatar) - Assets/Scripts/Gameplay/GameplayObjects/Character/ \ Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacter.cs
- Character movements - Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacterMovement.cs
- Client driven movements - Boss Room is server driven with anticipation animation. See Client Driven bitesize for client driven gameplay
- Player spawn - SpawnPlayer() in Assets/Scripts/Gameplay/GameState/ServerBossRoomState.cs
Boss Room includes the following game flow resources:
- Application Controller - Assets/Scripts/ApplicationLifecycle/ApplicationController.cs
- Game flow state machine - All child classes in Assets/Scripts/Gameplay/GameState/GameStateBehaviour.cs
- Scene loading and progress sharing - ackages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/
- Synced UI with character select - Assets/Scripts/Gameplay/GameState/ClientCharSelectState.cs
- In-game lobby (character selection) - Assets/Scripts/Gameplay/GameState/NetworkCharSelection.cs \ Assets/Scripts/Gameplay/GameState/ServerCharSelectState.cs
- Win state - Assets/Scripts/Gameplay/GameState/PersistentGameState.cs
Boss Room includes the following connectivity resources:
- Connection approval return value with custom messaging - WaitToDenyApproval() in Assets/Scripts/ConnectionManagement/ConnectionState/HostingState.cs
- Connection state machine - Assets/Scripts/ConnectionManagement/ConnectionManager.cs \ Assets/Scripts/ConnectionManagement/ConnectionState/
- Session manager - Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs
- RTT stats - Assets/Scripts/Utils/NetworkOverlay/NetworkStats.cs
Boss Room supports integration with Lobby, Relay, and Authentication (UAS). Boss Room includes the following service resources:
- Lobby and relay - host creation - CreateLobbyRequest() in Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs
- Lobby and relay - client join - JoinLobbyRequest() in Assets/Scripts/Gameplay/UI/Lobby/LobbyUIMediator.cs
- Relay Join - StartClientLobby() in Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs
- Relay Create - StartHostLobby() in Assets/Scripts/ConnectionManagement/ConnectionState/OfflineState.cs
- Authentication - EnsurePlayerIsAuthorized() in Assets/Scripts/UnityServices/Auth/AuthenticationServiceFacade.cs
Tools and utilities
Boss Room includes the following tools and utilities:
- Networked message channel (inter-class and networked messaging) - Assets/Scripts/Infrastructure/PubSub/NetworkedMessageChannel.cs
- Simple interpolation - Assets/Scripts/Utils/PositionLerper.cs
- Network Object Pooling - Assets/Scripts/Infrastructure/NetworkObjectPool.cs
- NetworkGuid - Assets/Scripts/Infrastructure/NetworkGuid.cs
- Netcode hooks - Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetcodeHooks.cs
- Spawner for in-scene objects - Packages/com.unity.multiplayer.samples.coop/Utilities/Net/NetworkObjectSpawner.cs
- Session manager for reconnection - Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs
- Relay utils - Packages/com.unity.multiplayer.samples.coop/Utilities/Net/UnityRelayUtilities.cs
- Client authority - Packages/com.unity.multiplayer.samples.coop/Utilities/Net/ClientAuthority/ClientNetworkTransform.cs
- Scene utils with synced loading screens - Packages/com.unity.multiplayer.samples.coop/Utilities/SceneManagement/
- RNSM custom config - Packages/com.unity.multiplayer.samples.coop/Utilities/Net/RNSM/CustomNetStatsMonitorConfiguration.asset
- ParrelSync - Packages/manifest.json
Boss Room is licenced under the Unity Companion Licence. See LICENSE.md for more legal information.
Visit the following links to learn more about Unity Netcode and Boss Room.
- About Netcode for GameObjects
- Boss Room Actions Walkthrough
- NetworkObject Parenting inside Boss Room
- NetworkRigidbody inside Boss Room
- Dynamically spawning NetworkObject in Boss Room
The Bitesize Samples repository is currently being expanded and has a collection of smaller samples and games showcasing sub-features of NGO. You can review these samples with documentation to better understand our APIs and features.
Please check out CONTRIBUTING.md for full guidelines on submitting issues and PRs to Boss Room.
Our projects use the
git-flow branching strategy:
developbranch has all active development.
mainbranch has release versions.
To get the project on your machine, you need to clone the repository from GitHub using the following command-line command:
git clone https://github.com/Unity-Technologies/com.unity.multiplayer.samples.coop.git
Important: You should have Git LFS installed on your local machine.
Please check out CONTRIBUTING.md for guidelines on submitting issues and PRs to Boss Room!
Thank you for cloning Boss Room and taking a look at the project. To help us improve and build better samples in the future, please consider submitting feedback about your experiences with Boss Room. It'll only take a couple of minutes. Thanks!