How many players are in a scene?

do you know how can I get the number of players in a specific scene? I'm using Unity Photon's PUN 2, so, almost anything of PUN 1 won't work. Thanks.

Comments

  • Hi @SebGM2018,

    if you use PhotonNetwork.AutomaticallySyncScene, the number of clients in the scene is most likely the same as the number of clients in the room, which you can get by using PhotonNetwork.CurrentRoom.PlayerCount.

    If you don't use AutomaticallySyncScene and have clients loaded different scenes, the clients would have to publish the name of the scene they currently have loaded. This can be easily done by using the Custom Player Properties. Whenever a client has finished loading a scene, he can update his Custom Player Properties with the name of the current scene. These properties are automatically synchronized across each client in the same room. By iterating through the PhotonNetwork.PlayerList each client can check, which other client has loaded a certain scene.