Join/create room after disconnecting goes wrong
Options
When I create or join a room, everything seems to be okay. But when I disconnect from photon and create or join another room, I have 2 objects with mine photonview. The previous player with mine photonview does still exist. Anyone that could help me? It drives me crazy, I even don't know how to explain because of this headache. Please help me out
0
Answers
-
IBuckly said:
When I create or join a room, everything seems to be okay. But when I disconnect from photon and create or join another room, I have 2 objects with mine photonview. The previous player with mine photonview does still exist. Anyone that could help me? It drives me crazy, I even don't know how to explain because of this headache. Please help me out
Need your code. I can not help without code0 -
My code is quite simple.
In the NetworkManager, I use this part of script// This buttonEvent is only for the masterclient [PunRPC] public void LoadGame () { SceneManager.sceneLoaded += (scene, loadscene) => { if (SceneManager.GetActiveScene().name == "GameRoom") { Spawn(); } }; PhotonNetwork.LoadLevel("GameRoom"); } void Spawn() { GameObject g = PhotonNetwork.Instantiate("Player", new Vector3(Random.Range(-2.7F, 1.1F), 0, Random.Range(-22F, -16.5F)), Quaternion.Euler(0, 90, 0), 0); }
And ingame, I use this partpublic void ReturnToMenu() { PhotonNetwork.autoCleanUpPlayerObjects = true; PhotonNetwork.Disconnect(); Application.LoadLevel("MainMenu"); }
0 -
Anyone??0
-
How are you calling the RPC ? I mean what are the sender options you set ?0
-
The RPC call is for All. Not AllBuffered if this is what you mean.0
-
I am not exactly sure how you are calling the rpc in your code but with the "All" option the RPC will be called immediately on the calling client and then sent to others. Are you by any chance calling Spawn locally on the client and then calling the RPC, in which case the code will be executed twice and would explain the 2 instances. In that case "Others" would be the PhotonTarget to use.0
-
This is how I call the RPC for the Spawn ();
Any idea how I can find if I call it locally?void Spawn() { GameObject g = PhotonNetwork.Instantiate("Player", new Vector3(Random.Range(-2.7F, 1.1F), 0, Random.Range(-22F, -16.5F)), Quaternion.Euler(0, 90, 0), 0); } //The Start button is only visible for the master client (the one that creates the room) if (PhotonNetwork.isMasterClient) { RoomStartMessage.text = "Press the 'Start game' button to load the game"; StartGameObject.transform.GetComponent<Button>().onClick.AddListener(() => { PhotonNetwork.room.IsOpen = false; photonView.RPC("LoadGame", PhotonTargets.Others); }); } [PunRPC] public void LoadGame () { SceneManager.sceneLoaded += (scene, loadscene) => { if (SceneManager.GetActiveScene().name == "11-Online") { Spawn(); } }; PhotonNetwork.LoadLevel("11-Online"); }
0 -
I still can't fix this problem. Someone? I really need help0
-
Just leave it. No one that helps... I just fixed it myself... Thanks to myself0