- Home /
Photon PUN offline mode didn't work
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
Answer by fblast1 · May 07, 2020 at 06:52 PM
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
Ho ! I'm sorry I thought it was automatic. No in this case I don't think it's a system to create a room. I'll try to do it.
That was it. I think it's working now. Thanks for your help, it's very strange how it worked before without me having to tell him to join a room. Thanks for your time.
Answer by TPorteau · May 07, 2020 at 07:51 AM
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.
this should gives a bunch of messages and for the callbacks it should execute , check those and review the callbacks
https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/lobby https://doc-api.photonengine.com/en/pun/v2/class_photon_1_1_pun_1_1_utility_scripts_1_1_on_joined_instantiate.html#a50318462f4512ceacacfe57c3af3f50c
try to set static region and connect in online mode and check callback calls
try force a disconnect to the server then activate the offline mode then create the room see if it works
Regards
I tried to connect with another client in online, everything works, and the callbacks works to.
well, can you disable instantiating e.g., player prefab or anything at room creation step to see if it creates a room successfully in offline mode
I tried to remove the prefab instantiation on launch, no errors. Then I tried to make it spawn in runtime, and the same error happened. "Can not Instantiate before the client joined/created a room. State: ConnectedTo$$anonymous$$aster"
it should work in that sequence
offline mode on
create room
instantiate
is that the order you have?
Regards
Yes, he send me a "Connected to $$anonymous$$aster" and the second I create a prefab he send me an error.
Your answer
Follow this Question
Related Questions
[PUN] Why is my Photon script not working? Help! 1 Answer
[Photon] How to sync own physic 0 Answers
Photon Player Property failing to update? 0 Answers
How to check distance between two players (photon multiplayer) 2 Answers
How To List Rooms (PUN 2) 1 Answer