Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Third Party Photon level restart problem

Discussion in 'Multiplayer' started by NovaSurfer, Mar 26, 2015.

  1. NovaSurfer

    NovaSurfer

    Joined:
    May 18, 2014
    Posts:
    11
    Hello everyone,
    I got some problems with PhotonNetwork.LoadLevel().
    Here is my code:
    Code (CSharp):
    1.  void OnCollisionEnter2D(Collision2D coll)
    2.     {
    3.         if (coll.gameObject.tag == "end")
    4.         {
    5.             PhotonNetwork.player.AddScore(1);
    6.             photonView.RPC("Restart", PhotonTargets.All);
    7.         }
    8.     }
    9.  
    10. [RPC]
    11.     void Restart()
    12.     {
    13.         if (PhotonNetwork.isNonMasterClientInRoom || PhotonNetwork.isMasterClient)
    14.         {
    15.             PhotonNetwork.isMessageQueueRunning = false;
    16.             PhotonNetwork.LoadLevel(1);
    17.         }
    18.     }
    Two clients connected.
    After restart everything is okay, but i got warning in console: Received OnSerialization for view ID [someId]. We have no such PhotonView! Ignored this if you're leaving a room. State: Joined
    And after rejoining the room there is 3 players not 2.
    I know that i need to turn off the PhotonNetwork.isMessageQueueRunning
    before restart and turn it on after restart. But it doesn't work.

    Excuse my English!
    Thanks.

     
  2. NovaSurfer

    NovaSurfer

    Joined:
    May 18, 2014
    Posts:
    11
  3. NovaSurfer

    NovaSurfer

    Joined:
    May 18, 2014
    Posts:
    11
    I solve problem with 3 player gameObjects when only 2 are connected.
    Code (CSharp):
    1.     [RPC]
    2.     void Restart()
    3.     {
    4.         if (PhotonNetwork.isNonMasterClientInRoom || PhotonNetwork.isMasterClient)
    5.         {
    6.             PhotonNetwork.DestroyPlayerObjects(PhotonNetwork.player.ID);
    7.             PhotonNetwork.LoadLevel(1);
    8.         }
    9.     }
    And the same when OnLeftRoom() called:
    Code (CSharp):
    1. void OnLeftRoom()
    2.     {
    3.         PhotonNetwork.DestroyPlayerObjects(PhotonNetwork.player.ID);
    4.     }
    But warning in console is still there
     
    Last edited: Mar 27, 2015
  4. NovaSurfer

    NovaSurfer

    Joined:
    May 18, 2014
    Posts:
    11
    And finally i fix it by using PhotonView.DontDestroyOnLoad() on start.
     
  5. alexanderkudryavy

    alexanderkudryavy

    Joined:
    Sep 20, 2019
    Posts:
    13
    NovaSurfer, I have the same problem right now, on what object you use "PhotonView.DontDestroyOnLoad() on start"?