The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

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).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

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

jeanfabre
2016-12-02 11:45:12

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

afa
2021-07-31 19:37:53

@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 ?

jeanfabre
2021-08-02 07:53:07

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