Photon Network get players in a room

Hi,

I’m using the Photon Network, and I was wondering how to get the players that are currently in the room? Like their player name, etc.

Thanks.

Hi,

You can use:

PhotonNetwork.playerList - List of ALL player in the room.

Or you can use:

PhotonNetwork.playerName and PhotonNetwork.otherPlayers - Your player and list of others players.

here is how you list players name in current room in Photon Unity Networking PUN2

public void AddAllActivePlayers()
    {
        Dictionary<int, Photon.Realtime.Player> pList = Photon.Pun.PhotonNetwork.CurrentRoom.Players;
        foreach (KeyValuePair<int, Photon.Realtime.Player> p in pList)
        {
            print(p.Value.NickName );
        }
    }