JoinRandomRoom continuous entering the same room

When I pressed the button, PhotonNetwork.JoinRandomRoom command works, but continuously enters the same room out of others rooms.i tried 5 different room . what would be the reason


  • JohnTubeJohnTube mod
    edited December 2020
    Hi @Huseyin,

    thank you for choosing Photon!

    This issue should not be happing.
    Make sure that you are using the same session (not disconnecting each time) and the same UserId.
    What exact client code (copy paste here with proper format) do you use to join random rooms then leave them to try to join another random one?

    UPDATE: see @Kaiserludi's answer below.
  • This sounds like a UI issue. Maybe all your buttons pass the same room name?

  • sorry for my late reply
    the problem is: When I clicked the play now button, it always entering the first created room.
    If the first room is occupied, it entering the second established room(because now first)
    When I clicked the play now button, this code works.
    public void Playnow_button()
    PhotonNetwork.JoinRandomRoom();//If there is no room ready, I'm setting it up, it's okay
    public void LeaveRoom_button()//when leaving the room
    PhotonNetwork.CurrentRoom.IsVisible = true;
    PhotonNetwork.CurrentRoom.IsOpen = true;
    public override void OnLeftRoom()//i used pun asteroid demo codes to clear the list
    foreach (GameObject entry in playerListEntries.Values)
    playerListEntries = null;

    i used pun asteroid demo codes when listing rooms.
    public override void OnRoomListUpdate(List<RoomInfo> roomList)//These are the asteroid demo codes
  • Tobias wrote: »
    This sounds like a UI issue. Maybe all your buttons pass the same room name?

    I have 2 buttons playnow_button and findroom_button.
    When I press the findroom_button I select it from the list, no problem, it works. I am entering any room I want.
    playnow_button doesn't work properly
  • KaiserludiKaiserludi admin
    edited December 2020
    Hi @Huseyin.

    What you observe is the intended default behavior.
    By default OpJoinRandomRoom() uses MatchMakingMode::FillRoom to fill one room after the other to minimize the users waiting time until all slots in the room they are in have been occupied and the match can start.
    It's basically the client telling the server "let me join the first room that you can find that matches my criteria".
    If you truly want truly random distribution over all open rooms that meet your criteria (which usually makes less sense as it leads to many users waiting for more players in half-filled rooms, while they could already be playing if they had all joined the same room!), then you can achieve this by setting OpJoinRandomRoomParams.MatchingType to MatchMakingMode::RandomMatching.

  • got it, thanks for your help
Sign In or Register to comment.