I develop an online game and to test it I use a script with “PhotonNetwork.OfflineMode = true;” in Awake(), it worked very well, but I don’t know why, since a few days it doesn’t work anymore.
Then I get an error of this type: “Can not Instantiate before the client joined/created a room. State: ConnectedToMaster”, after doing some research it seems that Photon doesn’t create a room when I press play.
When I connect to another player with two clients, however, everything works properly.
I’m a bit lost and despite my search I didn’t manage to solve my problem.
Thank you in advance for your help. Let me know if you want more information.
Well,
try enabling log messages of Photon from the toolbar in order to see what exactly happens
also you can implement callbacks for onCreated and onJoined to see what happens
lastly try changing region if it is auto set it manually and see if it creates one
Regards
Hi, fblast1 I tried to put this in one of my scripts with MonoBehaviourPunCallbacks :
public override void OnCreateRoomFailed(short returnCode, string message)
{
base.OnCreateRoomFailed(returnCode, message);
Debug.Log("Room failed");
}
public override void OnCreatedRoom()
{
base.OnCreatedRoom();
Debug.Log("Room created");
}
public override void OnJoinedRoom()
{
base.OnJoinedRoom();
Debug.Log("Room joined");
}
And I activate this in the server settings :
But nothing happens, maybe I’m in a bad way, or maybe that’s not what you want me to do.
yea it sometimes doesn’t work .
By the way after you set offline mode to true , how do you create the room ? , you know even in offline you must create one.
Regards
I found the solution
void Start()
{
PhotonNetwork.Disconnect();
//PhotonNetwork.OfflineMode = true;
loading.SetActive(false);
}
public void OnConnectButtonPressed()
{
Debug.Log("Connecting to Master");
PhotonNetwork.ConnectUsingSettings();
loading.SetActive(false);
PhotonNetwork.OfflineMode = false;
}
public void OnDisconnectButtonPressed()
{
PhotonNetwork.Disconnect();
PhotonNetwork.OfflineMode = true;
}