Check Players In Room
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Check Players In Room
LeoMantooo
2016-12-01 17:02:01
Hello everyone!
I'm trying to create a little multiplayer videogame in C# with photon and Unity...
I want that (when player is in a room) there is a text on screen which show the numbers of players in the room. Is it possible?
Thanks, LeoMantooo.
Comments
Hi,
yes, it's perfectly doable.
There is a property called PhotonNetwork.PlayerList which will tell you the number of players in the current room.
PhotonNetwork.playerList.Length
So this is what you need to show in your UI.
Bye,
Jean
@jeanfabre wrote: »
Hi,
yes, it's perfectly doable.
There is a property called PhotonNetwork.PlayerList which will tell you the number of players in the current room.
PhotonNetwork.playerList.Length
So this is what you need to show in your UI.
Bye,
Jean
how to check if there are 2 player in a room ?
if(PhotonNetwork.playerList.Length = 2){
}
is this correct ?
Hi,
there is a player count property inside the room class, so query PhotonNetwork.CurrentRoom.PlayerCount
https://doc-api.photonengine.com/en/pun/v1/class_room.html#a9e7c93f447ab113f8b6f8fed1502b997
Bye,
Jean
Back to top