Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

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:
    270
    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:
    528
    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,021
  4. jlorenzi

    jlorenzi

    Joined:
    May 2, 2021
    Posts:
    270
    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