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.

How do I make a "Players Online" count in a lobby?

Seth01Master
2022-04-01 18:01:47

Hello!

I am currently using Photon PUN to make a multiplayer game in unity. However, while making the menu, I thought it would be really cool to have a counter showing how many players were online and using the app. I looked all over the internet and could not find anything. Can anyone help me with this?

I don't need any GUI scripts or anything, just a way to find how many people are using the app at a time using C#. Thanks!

Comments

Klover
2022-04-02 10:02:25

int playersOnline = PhotonNetwork.PlayerList.Length;

Klover
2022-04-02 10:05:02

Also get the players names. You would have to assign each player a NickName over the network though

foreach(Player player in PhotonNetwork.PlayerList)

{

Debug.Log(player.NickName);

}

Seth01Master
2022-04-03 17:47:45

would that count how many people are using the app or just how many people are in a room/lobby?

Tobias
2022-04-04 12:01:52

Better use PhotonNetwork.CountOfPlayer.

The xml doc comment in the code tells you: "The count of players currently using this application (available on MasterServer in 5sec intervals)."

Back to top