-1

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.

Sergio Marquez
  • 111
  • 1
  • 11

1 Answers1

1

The PhotonNetwork class in the Photon.Pun namespace has a static property CurrentRoom where you can get the number of player in a room.

using Photon.Pun;

public static class MultiplayerHelper
{
    public static int GetPlayerCount() 
    {
        if (PhotonNetwork.CurrentRoom != null)
        {
            return PhotonNetwork.CurrentRoom.PlayerCount;
        }
        return 0;
    }   
}
JeanLuc
  • 4,783
  • 1
  • 33
  • 47