Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Third Party SOLVED Player Not able to join room using Photon

Discussion in 'Multiplayer' started by VeryNewAtThis, Jun 20, 2021.

  1. VeryNewAtThis

    VeryNewAtThis

    Joined:
    Jun 21, 2020
    Posts:
    5
    Hi all, I have been trying to allow the user to join rooms and have provided two options. They can either join a random room or join a room based on the room's name. While joining a random room works, joining a room based on name doesn't. It doesn't show errors but when I check for current room it shows null. In addition, if i press join room again it won't show an error (such as client is on game server). I am not sure why it isn't working. I don't believe that it is a server location issue as I have found on many threads (join random room works). If anyone has any ideas as to the issues

    Code (CSharp):
    1. using Photon.Pun;
    2. using TMPro;
    3. using UnityEngine;
    4.  
    5. public class FindRoomHandler : MonoBehaviour
    6. {
    7.     [SerializeField] private TMP_Text text;
    8.     public void JoinRoomName()
    9.     {
    10.         Debug.Log(text.text);
    11.         OnLaunch.JoinRoom(text);
    12.         Debug.Log(PhotonNetwork.CurrentRoom);
    13.         if (PhotonNetwork.CurrentRoom == null)
    14.         {
    15.             // show error
    16.         }
    17.         else
    18.         {
    19.             // join room
    20.         }
    21.     }
    22.  
    23.     public void JoinRandom()
    24.     {
    25.         PhotonNetwork.JoinRandomRoom();
    26.         if (PhotonNetwork.CurrentRoom == null)
    27.         {
    28.             // show error
    29.         }
    30.         else
    31.         {
    32.             // join room
    33.         }
    34.     }
    35. }
    36.  
     
  2. VeryNewAtThis

    VeryNewAtThis

    Joined:
    Jun 21, 2020
    Posts:
    5
    Follow up... I got this to work now. I moved all of the room menus into one scene and standardised the code of starting a room for both the master and non-master clients in starting a room. Doing this pretty much fixed everything.
     
    cjcleveland08 likes this.
  3. Hamzaburger1

    Hamzaburger1

    Joined:
    Aug 11, 2021
    Posts:
    1
    Can you pls be more specific
     
  4. anurrag116_unity

    anurrag116_unity

    Joined:
    Mar 8, 2021
    Posts:
    1