Under active development. Features and behaviors may change.
Target Audience: Game developers familiar with Unity and multiplayer networking
This project demonstrates a complete multiplayer game flow using FishNet for network object synchronization and brainCloud for user authentication, matchmaking, lobby management, and real-time relay transport.
The core integration replaces FishNet's default transport with brainCloud's relay service, enabling you to write multiplayer logic with FishNet while delegating matchmaking and relay connectivity to brainCloud.
- Unity 2021 or later
- FishNet Unity package
- brainCloud Unity SDK
- Valid brainCloud App ID and Secret (configured in Unity Inspector)
- Clone this repository and open the Unity project.
- Open the
Mainscene and run it in the Unity Editor.
- Authenticate and enter the lobby.
- Choose a lobby option and click "Ready Up".
- The game scene will load when all players are ready.
-
Modular Transport Layer
brainCloudTransportimplements FishNet’sTransportclass, enabling brainCloud to function as FishNet's network backend.- Plug-and-play: No need to modify FishNet’s core. Simply attach this component to your
NetworkManager.
-
Lobby to Relay Flow
- Game starts with brainCloud lobby services.
- Once the host is ready, the assigned relay server endpoint is used to initialize FishNet's connection through brainCloud's relay servers.
-
Real-Time Messaging
- Reliable and unreliable messages are routed through brainCloud's real-time relay.
- Internal buffer queues manage data inflow to ensure a smooth handoff to FishNet.
-
Player Metadata Sync
- Players are assigned random colors and names.
- This metadata is serialized and synced to all clients during session startup.
- The lobby and game session support mid-session joins, and metadata (including color and name) is correctly synced, even after host migration.
-
Scene Flow
- Login → Lobby Selection → Matchmaking → Relay Connect → Game Start
-
Authentication
- Use one of the four player options to log in.
- Note: Currently logs in anonymously using brainCloud.
-
Lobby Interaction
- Choose from:
- Create Game
- Quick Find (finds or creates a game)
- Find Game (manual search)
- Choose from:
-
Room Assignment
- Displays room code and participant list.
- Waits for players to click "Ready Up".
-
Relay Transport Setup
- Once all players are ready, the
ROOM_ASSIGNEDevent is triggered. brainCloudTransporttakes over and establishes a connection via FishNet using the provided relay parameters.
- Once all players are ready, the
-
Multiplayer Session Begins
- Players appear and interact in real time.
- Movement, actions (shockwave), paint splat trails, and player properties are synchronized using FishNet.
If you're new to Unity networking:
- Focus first on the flow in the
BCScripts/folder. - Real-time networking is abstracted. You do not need to modify
BrainCloudTransport.csunless customizing packet handling. - Use the Unity Inspector to assign references as needed (e.g., login UI, player prefab).
Matchmaking, relay connectivity, and real-time sync are provided using a modular, pluggable approach. This lets you focus on gameplay logic and player experience.
| Script | Purpose |
|---|---|
BrainCloudTransport.cs |
Custom transport layer for FishNet using brainCloud relay |
This folder contains the FishNet transport plugin implementation for brainCloud:
BrainCloudTransport.cs- Implements FishNet's
Transportabstract class. - Uses brainCloud's
RelayCommssystem to send and receive messages. - Buffers incoming packets and dispatches them via FishNet.
- Provides connection lifecycle methods (
StartClient,StartServer,StopConnection). - Supports host migration.
- Implements FishNet's
Purpose:
This is a drop-in FishNet transport backend powered by brainCloud. Plug BrainCloudTransport into your NetworkManager to enable real-time communication through brainCloud’s relay servers.
This folder contains game logic and UI scripts that support user flow.
- Support for persistent levels when new players join or during host migration
- Measure and display time taken to enter a hosted and launched session
For more information on brainCloud and its services, see the brainCloud Learn and API Reference pages.