- Home /
JoinRandomRoom failed. Client is on MasterServer (must be Master Server for matchmaking) but not ready for operations (State: PeerCreated). Wait for callback: OnJoinedLobby or OnConnectedToMaster.
I am trying to make a multiplayer game but I got this error every time I try to start the game and spawn the players. Can you help me with what I should do? I use this code for joining the room: ![using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon; using Photon.Pun; using UnityEngine.UI; using Photon.Realtime;
public class MPManager : MonoBehaviourPunCallbacks
{
public PlayFabAuth auth;
public string GameVersion;
public Text connectState;
public GameObject[] DisableOnConnected;
public GameObject[] DisableOnJoinRoom;
public GameObject[] EnableOnConnected;
public GameObject[] EnableOnJoinRoom;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void FixedUpdate()
{
connectState.text = "Is Connected: " + PhotonNetwork.IsConnected;
}
public void ConnectToMaster()
{
// PhotonNetwork.connectionStateDetailed
PhotonNetwork.ConnectToRegion("EU");
}
public virtual void onConnectedToMaster()
{
foreach(GameObject disable in DisableOnConnected)
{
disable.SetActive(false);
}
foreach(GameObject enable in EnableOnConnected)
{
enable.SetActive(true);
}
}
public void CreateOrJoin()
{
PhotonNetwork.JoinRandomRoom();
}
public virtual void OnPhotonRandomJoinFailed()
{
RoomOptions rm = new RoomOptions
{
MaxPlayers = 3,
IsVisible = true
};
int rndID = Random.Range(0, 3000);
PhotonNetwork.CreateRoom("Default: "+rndID, rm, TypedLobby.Default);
}
public virtual void OnJoinRoom()
{
foreach (GameObject disable in DisableOnJoinRoom)
{
disable.SetActive(false);
}
foreach (GameObject enable in EnableOnJoinRoom)
{
enable.SetActive(true);
}
GameObject player = PhotonNetwork.Instantiate("Player", Vector3.zero, Quaternion.identity, 0);
}
}][1]
![alt text][2]
[1]: /storage/temp/155619-captura-de-ecran-din-2020-04-01-la-150332.png
[2]: /storage/temp/155620-captura-de-ecran-din-2020-04-01-la-154338.png
Did you make sure OnConnectedTo$$anonymous$$aster was called? And please don't answer "yes" blindly here since you have a typo in that functions name...
Your answer
![](https://koobas.hobune.stream/wayback/20220612230242im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to display player coins on multiplayer 1 Answer
How to change colors in unity using photon? 0 Answers
how i instantiate a object make a prefabs at runtime i dont have to save in folder any thing.. 2 Answers
How to connect to our own dedicated server using photon networking in unity?(Self-hosted) 0 Answers
Light.color Sync ? 1 Answer