Hello, I just started using PUN 2 and recently I made a pause menu to my multiplayer game and in the pause menu there is a Disconnect button.
public void Disconnect()
{
PhotonNetwork.LeaveRoom();
SceneManager.LoadScene(0);
}
And when I press the button i get this error “ operation set (252) not called because client is not connected or not ready yet. client state leaving”. I am wondering does that mean that my player is not fully connected, because I am having another problem which is that sometimes only one of the players sees the player, does it have something to do with the error and how can I fix both issues? Thanks in advance!
We found an issue with SetProperties recently and fixed it in PUN 2.18.1. Maybe you update and give it another go.
If this is v2.18.1, we’d need to know more about the timing of this use case.
After leaving a room, we need to apply properties locally but not send them. This check apparently isn’t working in your case.
Hello, thanks for the reply! I am using PUN 2.18.1 and sometimes when I press disconnect and I get the error but then it does not go back to the menu scene.
You should stop calling the operation (with code 252) once you disconnect. Apparently your code continues to call it.
Along with the error code, you get a callstack. Check which code called the operation and make sure it only runs while connected.
@tobiass I have been having this problem. So far I have checked. It seems the PhotonMono is still not destroyed. Scenario:
After the multiplayer match is done. Result screen is showed, then clicking back to go to main menu is causing this issue. before calling main menu scene. I called leave room & Disconnect. But, when it reaches mainmenu. PhotonMono GO is not destroyed and its calling PhotonNetwork.NewSceneLoaded(); at Start().
Why PhotonMono is not destroyed. Am I doing something wrong?
public void OnLoadMainMenu ()
{
PhotonNetwork.LeaveRoom();
PhotonNetwork.Disconnect();
SceneManager.LoadScene(1);
}
After looked into some other forums. I have tried this code:
PhotonMono is PUN’s integration with Unity engine events. Some are only available to MonoBehaviours, so PhotonMono is created at runtime and marked with DontDestoryOnLoad. It has to stay there, even when you disconnect.
@tobiass Ya, But, when it loads back to main menu from Multiplayer scene (Where I called Leave Room & Disconnect).
Photon Network call is initiating from the start of that function.
So, that’s what causing me the issue Operation set (252)
I’m getting the same issue. It seems to only happen when I’m trying to rejoin a room.
As you can see in my logs, isConnectedAndReady is TRUE before I attempt to call RejoinRoom. And despite getting the error, it still successfully joins the room afterward.
public void OnClick_RestartGame()
{
PhotonNetwork.LeaveRoom();
}
public override void OnLeftRoom()
{
SceneManager.LoadScene(“Lobby”);
base.OnLeftRoom();
}
I have my restart game attached to a button, with the above code. Yet, I can’t seem to get this to work. What am I doing wrong? I just want to load from game scene back to lobby scene.
Is this PUN 2? The script which implements OnLeftRoom seems to extend MonoBehaviourPunCallbacks? Make sure this script’s OnEnable() / OnDisable() call base (so they get registered for the callback).
Enable the SupportLogger in the settings and check if that also doesn’t log OnLeftRoom().
Hi I have the same issue but a bit forward so I called (PhotonNetwork.LeaveRoom() and then the game freeze and its not disconnecting, there is no error and the player have being destroy like it should be but its just stop.
look: