- Home /
 
Why doesn't this work
When i try and create a room using photon networking, it doesn't create and i have absolutely no cue why, i've tried debugging and i can't find the issue. Here is my code:
 using UnityEngine;
 using System.Collections;
  
  public class StartRoom : MonoBehaviour {
      public UnityEngine.UI.InputField input;
      public string RoomName="";
      // Use this for initialization
      void Start () 
      {
  
      }
      
      // Update is called once per frame
      void Update () 
      {
          RoomName=input.value;
          if(Input.GetKeyDown(KeyCode.Return))
          {
          RoomName=input.value;
          StartRoomByName();
          }
          //Debug.Log(PhotonNetwork.GetRoomList().Length);
      }
  
  
      void StartRoomByName()
      {
          PhotonNetwork.ConnectUsingSettings ("1.0");
  
      }
  
      void OnGUI()
      {
          GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
      }
      void OnJoinedLobby()
      {
          PhotonNetwork.CreateRoom (RoomName);
      }
      void OnCreatedRoom()
      {
          PhotonNetwork.JoinRoom (RoomName);
      }
      
  
  }
 
               And here is the error i keep getting:
 JoinRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.
  UnityEngine.Debug:LogError(Object)
  PhotonNetwork:JoinRoom(String) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:1575)
  StartRoom:OnCreatedRoom() (at Assets/StartRoom.cs:42)
 
              Answer by tobiass · Feb 13, 2015 at 01:14 PM
You don't have to join the room when you created it. This is done implicitly for you!
Due to that, you can't join a room in the callback OnCreatedRoom() like you do.
Answer by Livindaki · Jul 08, 2019 at 11:15 AM
Tobiass :you can't join a room in the callback OnCreatedRoom() like you do if not like that .. so please how ?
Your answer
 
             Follow this Question
Related Questions
Networking : Loading the room's map. 3 Answers
Players connecting to different room. (Photon PunBasics Demo) 0 Answers
Why does Photon find a room so quick! 1 Answer
In Photon what is the difference between OnJoinedRoom() and OnPHotonPlayerConnected() 1 Answer
InvalidCastException when Instantiating with photon (PUN) 2 Answers