CreateRoom failed. Client is on GameServer

Options

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.UI;


using Photon.Pun;

using Photon.Realtime;


public class MenuManager : MonoBehaviourPunCallbacks

{

   public InputField CreateInput;

   public InputField CreateInputMaxPlayers;

   public InputField JoinInput;



   public void CreateRoom()

   {

       RoomOptions roomOptions = new RoomOptions();

       roomOptions.MaxPlayers = byte.Parse(CreateInputMaxPlayers.text);

       PhotonNetwork.CreateRoom(CreateInput.text, roomOptions);

       Debug.Log("Created");

   }



   public void JoinRoom()

   {

       PhotonNetwork.JoinRoom(JoinInput.text);

       Debug.Log("Connected");

   }


   public void OnJoinedRoom()

   {

       PhotonNetwork.LoadLevel("Game");

   }

}




CreateRoom failed. Client is on GameServer (must be Master Server for matchmaking) and ready. Wait for callback: OnJoinedLobby or OnConnectedToMaster.

UnityEngine.Debug:LogError (object)

Photon.Pun.PhotonNetwork:CreateRoom (string,Photon.Realtime.RoomOptions,Photon.Realtime.TypedLobby,string[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:1782)

MenuManager:CreateRoom () (at Assets/Scripts/MenuManager.cs:20)

UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:385)




Please help me!

Answers

  • Tobias
    Options

    Read the error message:

    CreateRoom failed. Client is on GameServer (must be Master Server for matchmaking) and ready. Wait for callback: OnJoinedLobby or OnConnectedToMaster.

    Translates to: You can not call CreateRoom while being in a room. First you need to leave the room, wait for OnConnectedToMaster callback (the client is back on the Master Server) and then create a room.