Room always showing 0 players

Client A creates a room, client B joins, OnPlayerEnteredRoom is called but the number of players always shows 0. I've tried PhotonNetwork.PlayerList.Length.

I should note when client A OnJoinedRoom is called PhotonNetwork.InRoom is returning false even though the state is joined.


  • Hi @Diggidy,

    make sure that both clients join and stay in the same room. Therefore both clients have to use the same AppId and the same Game / App Version (set in the PhotonServerSettings). Obviously both clients have to join the same room.

    Since you are already using the OnJoinedRoom callback, try using the OnLeftRoom callback, too. If it gets called, you know that the client is not in the room any longer.

    In your description, both mentioned values might not be updated when you access them. You can add Unity's OnGUI function to simply display those values on screen. Example:
    private void OnGUI()
        if (PhotonNetwork.InRoom)
            GUILayout.Label("Number of players: " + PhotonNetwork.PlayerList.Length);
            foreach(Player p in PhotonNetwork.PlayerList)
  • Thanks for the reply!

    I am using a Debug in OnLeftRoom but it doesnt get called, so it appears everyone is in the room.

    I tried with just 1 player but players in room is still 0 and PhotonNetwork.InRoom is still false. I disabled all room options to see if that had an effect, but it didnt. It appears the player is connecting but not appearing in the room.

    I am using the realtime demo script, I double checked the appID and it is correct (using my appID).
  • The Realtime demo doesn't make use of PUN. It's the other way around that PUN is built on top of Realtime to make things easier. You can't use any PhotonNetwork calls in Realtime. In Realtime you would have to use the active LoadbalancingClient (the one also used for connection) and access the CurrentRoom from there.

    As said: PUN utilizes Realtime to make things easier. An Example: while you have to call the Service function in Realtime on your own to make network progress, PUN handles this for your internally, you don't have to call it manually.
  • Ahhhhh, Ok. I'll look into the PUN demos.

Sign In or Register to comment.