💡 Utilities Package
This repository also contains a Utilities package, containing reusable sample scripts. You can install it using the following manifest file entry:
Requirements
compatible with the latest Unity Long Term Support (LTS) editor version, currently 2022 LTS. Please include standalone support for Windows/Mac in your installation.
PLEASE NOTE: You will also need Netcode for Game Objects to use these samples. See the Installation Documentation to prepare your environment. You can also complete the Get Started With NGO tutorial to familiarize yourself with Netcode For Game Objects.
developed and tested on the following platforms:
- Windows
- Mac
- iOS
- Android
min spec devices are:
- iPhone 6S
- Samsung Galaxy J2 Core
Installing Git LFS to clone locally
Git Large Files Support (LFS) is required to handle all large assets required locally.
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 installation.
-
Add the project to the Unity Hub by clicking on the Add button and pointing it to the root folder of the downloaded project.
- Please note : the first time you open the project Unity will import all assets, which will take longer than usual.
-
Hit the Play button. You can then host a new game or join an existing one using the in-game UI.
Exploring the project
an eight-player co-op RPG game experience, where players collaborate to fight imps, and then a boss. Players can select between classes that each have skills with didactically interesting networking characteristics. 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.
Registering the project with Unity Gaming Services (UGS)
Leverages several services from UGS to facilitate connectivity between players. To use these services inside your project, you must create an organization inside the Unity Dashboard, and enable the Relay and Lobby services. Otherwise, you can still use Boss Room without UGS.
Testing multiplayer
In order to see the multiplayer functionality in action we can either run multiple instances of the game locally on your computer - using either ParrelSync or builds - or choose to connect to a friend over the internet. See how to test for more info.
Local multiplayer setup
First, build an executable by clicking 'File/Build Settings' in the menu bar, and then click 'Build'.
Once the build has completed you can launch several instances of the built executable in order to both host and join a game. When using several instances locally, you will have to set different profiles for each instance for authentication purposes, by using the 'Change Profile' button.
💡 Mac users: To run multiple instances of the same app, you need to use the command line. Run open -n BossRoom.app
Multiplayer over Internet
To play over internet, first build an executable that is shared between all players - as above.
It is possible to connect between multiple instances of the same executable OR between executables and the editor that produced it.
Running the game over internet currently requires setting up a relay.
Relay Setup
-
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 a9998external 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 in this project
Click to expand/collapse contents
Gameplay
- 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
- Player camera setup (with cinemachine) - OnNetworkSpawn() in Assets/Scripts/Gameplay/GameplayObjects/Character/ClientCharacter.cs
- INetworkSerializable (bandwidth optimization) vs INetworkSerializeByMemcpy (performance optimization) usage. See LobbyPlayerState vs ActionID structs Assets/Scripts/Gameplay/GameState/NetworkCharSelection.cs vs Assets/Scripts/Gameplay/Action/ActionID.cs
Game Flow
- 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
Connectivity
- Disconnecting every client with reason - OnUserRequestedShutdown() in Assets/Scripts/ConnectionManagement/ConnectionState/HostingState.cs
- Connection approval with reason sent to the client when denied - ApprovalCheck() in Assets/Scripts/ConnectionManagement/ConnectionState/HostingState.cs
- Connection state machine with error handling - Assets/Scripts/ConnectionManagement/ConnectionManager.cs
Assets/Scripts/ConnectionManagement/ConnectionState/ - UTP setup for IP - ConnectionMethodIP in Assets/Scripts/ConnectionManagement/ConnectionMethod.cs
- UTP setup for Relay - ConnectionMethodRelay in Assets/Scripts/ConnectionManagement/ConnectionMethod.cs
- Session manager - Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs
- RTT stats - Assets/Scripts/Utils/NetworkOverlay/NetworkStats.cs
Services (Lobby, Relay, etc)
- 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
- Subscribing to LobbyEvents - SubscribeToJoinedLobby() in Assets/Scripts/UnityServices/Lobbies/LobbyServiceFacade.cs
- Authentication - EnsurePlayerIsAuthorized() in Assets/Scripts/UnityServices/Auth/AuthenticationServiceFacade.cs
- Authentication - Profile management for ParrelSync/local instances - GetProfile() in Assets/Scripts/Utils/ProfileManager.cs
- Profile manager for ParrelSync and local play Assets/Scripts/Utils/ProfileManager.cs
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/
- 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
- NetworkSimulator usage through UI - Assets/Scripts/Utils/NetworkSimulatorUIMediator.cs
- ParrelSync - Packages/manifest.json
Troubleshooting
Documentation
Contributing
Our projects use the git-flow branching strategy:
- our
developbranch contains all active development - our
mainbranch contains release versions
Other samples
Bite-size Samples
- The Bitesize Samples repository is currently being expanded and contains a collection of smaller samples and games, showcasing sub-features of NGO. You can review these samples with documentation to understand our APIs and features better.


