Loading a scene in the context of Quantum involves two parts:
- the scene view (Unity); and,
- the scene data for the simulation (Quantum).
This document will present 3 valid approaches on how to implement scene loading. In all of them, you will want to load the Unity Scene and MapData yourself (via the
OnMapChanged callback for the later).
Simulation Config asset offers an Auto Load Scene from Map option. This is fine for prototyping, for production we strongly advise you to write your own game specific loader.
Load While Offline
The Unity Scene can be loaded offline/locally before a player enters matchmaking or starts a game. This is a good option for casual games with direct matchmaking.
- Load the gameplay scene in the background even while offline (Unity)
- Enter matchmaking and find a room (Photon Realtime)
- Start the simulation (Quantum) with the gameplay scene already pre-loaded
Load While In Photon Room
In case you need a lobby to inform players about pre-match information, you can coordinate the loading via the Photon Realtime APIs and launch the Quantum simulation as soon as everybody has loaded the gameplay scene.
Player joins a Photon ROOM
Coordinate the scene loading for all clients who joined the room via Realtime:
- Signal the expected load time with (custom Photon message or room property)
- Wait for all clients to confirm they have loaded the scene (player property), OR the master client signals a time out
- Signal the Quantum simulation start (room property)
When game starts, the simulation and gameplay kick-off immediately without any additional loading being required; this makes it fair for all players involved.
Load After Quantum Started
This options is similar to the previous one with one crucial difference: the lobby rules are controlled and enforced by the Quantum simulation. Going this route allows you to benefit from the determinism right away, this is particularly useful when pre-match rules need to be enforced - for instance character selection rules in MOBAs.
- Join a Room (Realtime)
- Start simulation (Quantum)
- Load gameplay scene (Unity)
- The gameplay scene has a lobby controlled by the simulation logic
- Players can use
SendPlayerDatawith their selections
- A time out is enforced by the lobby system (Quantum) thus maintaining determinism in case a client fails
- Disable the lobby systems in Quantum and enable the gameplay related ones