How to restart a game and keep all players in the room ?

Options
Hi, I have a board game, and I want to restart the game and keep the two players in the room, I could I do ?
Thanks

Comments

  • kosted
    Options
    I wrote this script. When it is the master client who runs the RPC all clients restart the game. But when it's a client, he restart his local game, the others are not affected. How to correct it please ?
    [PunRPC]
        public void Restart(int view)
        {
    
       PhotonNetwork.automaticallySyncScene = true;
            GameObject gameManager = PhotonView.Find(view).gameObject;
            PhotonNetwork.LoadLevel("Jeu");
    
            Text textD = GameObject.Find("TextDebug").GetComponent<Text>();
            textD.text = "je suis dedans";
            Debug.Log("je suis dedans");
            gameManager.GetComponent<PhotonView>().RPC("Restart", PhotonTargets.OthersBuffered, new object[] { view });
    
         
        }
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @kosted,

    I think you should start with Photon webhooks documentation. You need an external web server to save and load room state to be able to leave and resume games.
  • kosted
    Options
    JohnTube said:

    Hi @kosted,

    I think you should start with Photon webhooks documentation. You need an external web server to save and load room state to be able to leave and resume games.

    Hi @JohnTube , thanks for your answer. I don't want to leave and resume games. I just want want to restart for all players, for example, at the end of the game, the looser has to say if he wants to replay or not. If he wants to replays I restart everywhere (They are just just two players)
  • vadim
    Options
    Hi,
    Set PhotonNetwork.automaticallySyncScene = true and call PhotonNetwork.LoadLevel once on master client. Other clients will reload automatically.
    To trigger reloading from other client, send RPC to master asking it to reload.
  • kosted
    Options
    vadim said:

    Hi,
    Set PhotonNetwork.automaticallySyncScene = true and call PhotonNetwork.LoadLevel once on master client. Other clients will reload automatically.
    To trigger reloading from other client, send RPC to master asking it to reload.

    Ok thanks for this answer
  • kosted
    kosted
    edited May 2016
    Options
    vadim said:

    Hi,
    Set PhotonNetwork.automaticallySyncScene = true and call PhotonNetwork.LoadLevel once on master client. Other clients will reload automatically.
    To trigger reloading from other client, send RPC to master asking it to reload.

    I made this function but only the master reload. Why the client doesn't reload ?
    
      [PunRPC]
        public void PreparartionRestart(int view)
        {
    
            GameObject gameManager = PhotonView.Find(view).gameObject;
    
            Debug.Log("in the method");
            if(PhotonNetwork.isMasterClient) //If it is the master who lauch the method he reloads the scene
            {
                Debug.Log("in the  master");
                PhotonNetwork.automaticallySyncScene = true;
                PhotonNetwork.LoadLevel("Jeu");
            }
            else //when it is the client who launch the method he send RPC to master to reload
            {
                Text textD = GameObject.Find("TextDebug").GetComponent<Text>();
                textD.text = "call the master";
                gameManager.GetComponent<PhotonView>().RPC("PreparartionRestart", PhotonTargets.MasterClient, new object[] { view });
            }
        }
  • kosted
    Options
    up...
  • kosted
    Options
    Please help
  • jeanfabre
    Options
    Hi,

    If the client left the room it won't happen. you need to be in the room for level to be synchronized automatically. Could this be the case?

    Bye,

    Jean