JoinRandomRoom(null,2) never joins 2 people together

Options
I've been using PUN since version 1.28, and it's always been very easy to understand and use.

Today I updated PUN to version 1.64.2 (using Unity 5.2.3.f1), and now the PhotonNetwork.JoinRandomRoom(null,2) function fails to join 2 people together. This worked in versions prior to 1.64.2.

I have tried it with _both_ "AutoJoinLobby" on and off, but no matter what I do, JoinRandomRoom always fails, and people always just end up creating their own room.

What am I doing wrong?

void Start() { PhotonNetwork.ConnectUsingSettings("0.2"); } public override void OnConnectedToMaster() { print("Connected to Master, not joining lobby"); // this prints with AutoJoinLobby off ConnectRandomRoom(); } public override void OnJoinedLobby() { print("Connected to Master and Joined Lobby"); // this prints with AutoJoinLobby on ConnectRandomRoom(); } private void ConnectRandomRoom() { print("Joining a random room"); PhotonNetwork.JoinRandomRoom(null, 2); } // I expect this to get called ONCE for the first player // the first player does successfully create a room // but now with version 1.64.2, this is ALSO getting called for the second player public override void OnPhotonRandomJoinFailed(object[] codeAndMsg) { base.OnPhotonRandomJoinFailed(codeAndMsg); print("Can't join random room, creating a new one"); var roomOptions = new RoomOptions { isVisible = false, maxPlayers = 2 }; PhotonNetwork.CreateRoom(null, roomOptions, TypedLobby.Default); }

Comments

  • Tobias
    Options
    Please read the API documentation of JoinRandomRoom(null,2) does have a specific task but the second parameter is not the number of players you want in some room.

    Here's also a manual for the matchmaking in general:
    https://doc.photonengine.com/en/pun/current/tutorials/matchmaking-and-lobby
  • Tulrath
    Tulrath
    edited December 2015
    Options
    I removed the parameters from JoinRandomRoom, so now instead of JoinRandomRoom(null,2); it is now just JoinRandomRoom().

    But, it's still not working. This used to work.

    I have read this documentation many times:



    JoinRandomRoom() <-- with no parameters
    Joins any available room of the currently used lobby and fails if none is available.

    Rooms can be created in arbitrary lobbies which get created on demand. You can join rooms from any lobby without actually joining the lobby. Use the JoinRandomRoom overload with TypedLobby parameter.

    This method will only match rooms attached to one lobby! If you use many lobbies, you might have to repeat JoinRandomRoom, to find some fitting room. <b class="Bold">This method looks up a room in the currently active lobby or (if no lobby is joined) in the default lobby.

    If this fails, you can still create a room (and make this available for the next who uses JoinRandomRoom). Alternatively, try again in a moment.


    From this, it seems to be saying:
    • JoinRandomRoom() will look up a room in the currently active lobby of (if no lobby is joined) in the default lobby.
    • Because I am NOT joining a lobby, then that means it should lookup a room in the default lobby.
    • Therefore, if 2 players both use JoinRandomRoom() without parameters, then they should both lookup a room in the default lobby.
    • The first player to use JoinRandomRoom() should, therefore, create a room in the default lobby. [edit: I am catching the "OnPhotonRandomJoinFailed" and then executing a CreateRoom() - see the options I'm using below]
    • The second player should also lookup a room in the default lobby, but unlike player 1, player 2 should see the room created by player 1 as the only room option available... and join that one.

    Is this NOT how it works?

    Here is the CreateRoom() I"m using:

    var roomOptions = new RoomOptions { isVisible = false, maxPlayers = 2 };
    PhotonNetwork.CreateRoom(null, roomOptions, TypedLobby.Default);


    I have 2 sessions, and they both execute "JoinRandomRoom()" with no parameters. But instead of the 2nd session joining the first session, they BOTH create a new room.

    I still don't see what I'm doing wrong.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited December 2015
    Options
    Rooms created with IsVisible = false can't be joined randomly. They can be joined only by name.
    Please change it to true.

    This is the comment on IsVisible:
    Defines if this room is listed in the lobby. If not, it can't be joined randomly.
    A room that is not visible will be excluded from the room lists that are sent to the clients in lobbies.
    An invisible room can be joined by name but is excluded from random matchmaking.
    Use this to "hide" a room and simulate "private rooms". Players can exchange a roomname and create it invisble to avoid anyone else joining it.
    However, this still does not explain how it was working previously if you did not change the code.