Room Activity Failed. Client is not on MasterServer

Options
Hello Everyone,
I have some problem with PUN.
Basically, I cannot Create/Join/JoinOrCreate any Rooms while i'm connected to Master.
The reason is in this error:
CreateRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster..
I guess i'm connecting some kind of dummy way but I can't find what's a problem.

Here's what's going on NOW:
When I trigger Portal, I cannot join or create new Room but I load new scene and watch my friends floating around on the old Level

What I want to do:
When I trigger Portal, I create new Room and load new Level that Portal is pointing at.

For example: when I connect, I join base Room/Level via "Lobby" where I can create my own Room/Level and leave the "Lobby" Level alone. But unfortunately I load new Scene only and get "CreateRoom failed. Client is not on Master Server" error.

Any useful hints will be great
Many thanks)

PS OnLeftRoom didn't solve it, PortalInfo store string with Level/Room Name, I have two Scenes - "Demo" which is starting scene and "TestingRoom"
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
NetworkManager (which I grab on GameObject named "_STATIC" for each scene)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class NetworkManager : MonoBehaviour {
public GameObject LoadingCamera;
GameObject MyPlayerGO;
public Transform SpawnSpot;
void Start ()
{
if (PhotonNetwork.connectionStateDetailed.ToString() == "Joined") //if I been connected and just change the Room
{
SpawnMyPlayer();
}
else //if I connecting for the first time
{
PhotonNetwork.ConnectUsingSettings(null);
}
}

void OnConnectedToMaster() //Using this one, seems OnLobby isn't working, autoJoin is disabled
{
PhotonNetwork.JoinRandomRoom();
}

void OnPhotonRandomJoinFailed() //If we are alone
{
PhotonNetwork.CreateRoom("Demo");
}

void OnJoinedRoom()
{
SpawnMyPlayer();
}

void SpawnMyPlayer() //enabling MY player's controls
{
MyPlayerGO = PhotonNetwork.Instantiate("PlayerController", SpawnSpot.position, Quaternion.identity, 0);
((MonoBehaviour)MyPlayerGO.GetComponent("FirstPersonController")).enabled = true;
MyPlayerGO.GetComponentInChildren().enabled = true;
MyPlayerGO.GetComponentInChildren().enabled = true;
LoadingCamera.SetActive(false);
}

public void JoinOrCreateLevel(string LevelName) //void I call from ColliderActivator
{
AsyncOperation a = Application.LoadLevelAsync(LevelName);
a.allowSceneActivation = false;
PhotonNetwork.LeaveRoom();//Doesn't leave Room
PhotonNetwork.JoinOrCreateRoom(LevelName, new RoomOptions(), TypedLobby.Default);//Calls error
a.allowSceneActivation = true;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
ColliderActivator
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
public class ColliderActivator : MonoBehaviour {
public NetworkManager MyNetworkManager;
void Start()
{
MyNetworkManager = GameObject.Find("_STATIC").GetComponent();//Getting this scene's manager
}

void OnControllerColliderHit(ControllerColliderHit col) //if MY controller collide with objects by name:
{
switch (col.gameObject.name)
{
case "HexWithGravityActivator"://pointless
col.gameObject.GetComponent().useGravity = true;
break;
case "HexPortal"://portal which stores Room/Level Name - Target
MyNetworkManager.JoinOrCreateLevel(col.gameObject.GetComponent().Target);
break;
default:
break;
}
}
}

Comments

  • vadim
    Options
    If you want to create room, leave current room first. This will connect you to master server (the error states clearly that you not connected to it).
    Or just load new level in the same room.
  • Well what basically happens is when I load new level "B" I'm still in room "A". The problem is when I'm trying to leave Room and then create another I get an error described before. Is that possible to join Room "A" while you're nor connected to Master? I cant explain why I cannot leave my Room "A" and create new then...
  • When I say "Leave" I honestly leave Room, but then apparently join it again. There is no any another Room, but I want just stay ConnectedToMaster, not Joined again.