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.
Asked
Active
Viewed 1,136 times
-1
-
What code did you use in PUN 1? – JeanLuc Nov 15 '18 at 16:22
-
@JeanLuc I haven't used PUN 1 before, I'm a begginer starting with PUN 2 – Sergio Marquez Nov 16 '18 at 03:57
1 Answers
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