Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Third Party [Photon Pun2] Players not joining same lobby

Discussion in 'Multiplayer' started by jlorenzi, Sep 14, 2023.

  1. jlorenzi

    jlorenzi

    Joined:
    May 2, 2021
    Posts:
    328
    I'm trying to make a 2 player board game in Unity but when testing, both the players create their own rooms instead of the first player creating a room and the second player joining that room. I thought the JoinOrCreateRoom function meant that it would look for a room with the name provided and if there wasn't a room with that name, it would create it. But that doesn't seem to be how it's working.

    Code (CSharp):
    1.     public override void OnConnectedToMaster()
    2.     {
    3.         Debug.Log("Connected");
    4.         base.OnConnectedToMaster();
    5.  
    6.         RoomOptions roomOptions = new RoomOptions();
    7.         roomOptions.MaxPlayers = 2;
    8.         roomOptions.IsVisible = true;
    9.         roomOptions.IsOpen = true;
    10.  
    11.         PhotonNetwork.JoinOrCreateRoom("Room 1", roomOptions, TypedLobby.Default);
    12.     }
    I've tried increasing the max players value of the room but it didn't work. I don't know what else to try; please help!
     
  2. tleylan

    tleylan

    Joined:
    Jun 17, 2020
    Posts:
    698
    It is going to be rather hard to explain it a few messages. I would recommend that you join the Photon Discord server.

    I believe you have to be in a lobby BTW (I don't know how it works outside of VR but I believe the same) in which case you may need to call JoinLobby from OnConnectedToMaster.

    Best to get details from their Discord where they can probably point you to examples.
     
    jlorenzi likes this.
  3. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,086
  4. jlorenzi

    jlorenzi

    Joined:
    May 2, 2021
    Posts:
    328
    I don't think so since because I'm just running the game twice on my pc by building the game and starting it and then entering play mode in the Unity editor