Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Third Party [Photon] Getting player list without joining room?

Discussion in 'Multiplayer' started by Kovenant, May 7, 2015.

  1. Kovenant

    Kovenant

    Joined:
    Sep 18, 2013
    Posts:
    254
    I'm wondering if it's possible to get the playerList from a room without joining the room? Basically what I want to do is when you are in the "Join Game" menu and select a room from a list I want to list what players are online in that particular room in another window in the "Join Game" menu...Hope this makes sense :)
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,082
    We decided not to send the user list per room to clients. It's potentially a lot of content and usually not a lot of benefit. If the game is popular, there are hundreds of rooms and thousands of players (and names to send) who are unknown to you.
    Use FindFriend() to get a list of rooms known players are in.
     
  3. Kovenant

    Kovenant

    Joined:
    Sep 18, 2013
    Posts:
    254
    Is this something that would be possible to achieve if I download the Photon Server instead of using the Cloud?
     
  4. Aaron_T

    Aaron_T

    Joined:
    Sep 30, 2014
    Posts:
    123
    It is not possible by default, but you may be able to make a workaround using customRoomProperties to save player names and makes those properties available in the lobby.
    I have no idea how this would impact the network for users in the lobby, though, and wouldn't necessarily recommend it.
     
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,082
    @Kovenant: What effect do you want to achieve?
     
  6. Kovenant

    Kovenant

    Joined:
    Sep 18, 2013
    Posts:
    254
    Just to be able to see what players are online in a room before joining it.. I guess setting customRoomProperties can get the job done? You know, in Steam you can rightclick on a server to get what players are online and what their current score is and such. This is not a important feature of my game, so if it will do more harm than good it's no biggie :) @tobiass
     
  7. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,082
    If it's any good, depends a bit on the platform and play style. Yes, you can do this in steam and yes, we had long lists of servers in counterstrike. But times changed and at least on mobile it's considered essential that players get into some game quickly and conveniently. You usually don't know any of the others, so the names are white noise and dead traffic in most cases. Better build a few filters, like "map" or "game type" and pick a random room, unless you can find friends online.
    It's up to you. You can use the properties that way but we don't encourage that.
     
  8. Playzio

    Playzio

    Joined:
    Nov 7, 2016
    Posts:
    1
    can I get the count of players without joining the room. Like current online players count.
     
  9. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,082
    @Playzio: In Photon, the lobbies provide lists of rooms. In those, you get the player-count per room but not each player's name. PUN has a demo "Worker", which shows a room list. Have a look at it's simple code.

    You can also get the overall count of players and rooms in the region you're connected to. That's PhotonNetwork.countOfPlayers, .countOfRooms, etc..
     
  10. seunhart1

    seunhart1

    Joined:
    Dec 13, 2016
    Posts:
    3
    Hello,
    I am facing one issue regarding join room
    I have two modules one is custom and one is join random room

    In Custom i have friend list which i have created using my own services. When i send a request to my friend by creating a room with push then my player is waiting for friend to join that room and in the mean time if another 3rd user request for random room join then he joined a room which i have created for my friend. In my room Player count is 2 so my friend is unable to join the room and my module functionality fails in this case. How i can go for this?

    Thanks,
    Sean
     
  11. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,082
    You have 2 options:
    You can keep a room out of the matchmaking by making it invisible. Set roomOptions.IsVisible = false when you create the room. You can do that in PhotonNetwork.JoinOrCreateRoom().

    Alternatively, you could reserve a spot in the room, for the invited player. One overload of JoinOrCreateRoom() has the parameter string[] expectedUsers. When your friend's userID is in that array, the spot is reserved but others might join randomly (if the room had a higher maxplayers).
    Make sure you set AuthValues to set your own UserID per user.
     
  12. seunhart1

    seunhart1

    Joined:
    Dec 13, 2016
    Posts:
    3
    Thanks tobiass for your quick reply
     
    tobiass likes this.
  13. seunhart1

    seunhart1

    Joined:
    Dec 13, 2016
    Posts:
    3
    Hello

    I need one help. I am using Photon MultiPlayer sdk. I am facing one issue in that.
    I have created one room with Player count limit for that room 2. When both the Players joins the room both Players GameObjects are visible to each other. But when i lock my iPhone device and then unlock the device then one of the player GameObject disappears from my screen. Why this happened. Is this due to disconnecting to Photon server? If yes how i can maintain the state of the game in this situation?

    Thanks,
    Sean
     
  14. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,082
    This happens when the client gets disconnected from the server. iOS does not approve of general apps that keep connections alive...
    If you're OK with cleaning up GOs yourself, you can disable Autocleanup for those rooms. Have a look at
    PhotonNetwork.autoCleanUpPlayerObjects.