How to Restart a Game?

Options
Hi all, I couldn't find enough information about restarting a game. I have tried almost everything. In my game there are 2 players and after a game session they may request a rematch. But once they agreed I can't reload scene again. Master client works but other client is not working. Here is my code;

// Calling this function when they agreed
photonView.RPC("RestartGame", RpcTarget.All);

[PunRPC]
        public void RestartGame()
        {
              if (PhotonNetwork.IsMasterClient)
               {
                   PhotonNetwork.LoadLevel(6);
               }
        }

Note: Automatically sync scene is true.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @bariskaplan,

    Thank you for choosing Photon!

    Why do you need an RPC for this if you will just call LoadLevel?
    Maybe call it directly from the master client?

    instead of photonView.RPC("RestartGame", RpcTarget.All) just do photonView.RestartGame().
  • JohnTube wrote: »
    Hi @bariskaplan,

    Thank you for choosing Photon!

    Why do you need an RPC for this if you will just call LoadLevel?
    Maybe call it directly from the master client?

    instead of photonView.RPC("RestartGame", RpcTarget.All) just do photonView.RestartGame().

    Thank you for your answer. Yes you are right it is useless to call RPC function for just loading a level and checking if master client also. But I tried many combinations and after all, I left this useless code. Master client loading level but other client stays the same.

    I think main problem is "automatically sync scene" property. Even if its true, doesnt work for other client. So I solved my problem with manual resetting values in scene. Not calling any load level function.

    Thanks again.