Syncing a level between players
In Unity Networking, we had to develop our own way to make sure each player was running on the same level, via RPCs, disabling the network queue, waiting for the load to finish, and so on.
In Photon, this problem is significantly easier to solve. You simply set PhotonNetwork.automaticallySyncScene
to true, and to load a level call PhotonNetwork.LoadLevel
on the master client. For example, we can modify our lobby example to automatically sync the scene between players in a room.
Firstly, in Start
we would enable automatic level syncing:
void Start() { // ... // ensure that all players play on the same map PhotonNetwork.automaticallySyncScene = true; }
Then, when starting a game, we use PhotonNetwork's load level replacement ...
Get Unity Multiplayer Games now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.