- Home /
[Photon] Restart scene rpc doesn't work
Hi guys. I'm making a 2d board game and I use photon. At the end of the party the looser can decide to take his revenge and he restarts the game. The looser can be the master client or the client. But If it is the master client, when I execute the PunRPC method restart, the client restarts too. But the reverse doesn't work : if the client restart, he restarts only on his screen, and the master client is not affected. How to correct it please ? I want to keep the two players in the room, is the code correct ?
[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 });
}
You could try to simply call from the master client every time. Excuse the pseudo code, hope you get what I'm trying to say.
if (masterClient) {
Restart ();
} else {
$$anonymous$$asterClient.Restart ();
}
I made this function but only the master restart.
[PunRPC] public void PreparartionRestart(int view) {
GameObject game$$anonymous$$anager = PhotonView.Find(view).gameObject;
Debug.Log("in the method");
if(PhotonNetwork.is$$anonymous$$asterClient)
{
Debug.Log("in the master");
PhotonNetwork.LoadLevel("Jeu");
}
else
{
Text textD = GameObject.Find("TextDebug").GetComponent<Text>();
textD.text = "call the master";
game$$anonymous$$anager.GetComponent<PhotonView>().RPC("PreparartionRestart", PhotonTargets.$$anonymous$$asterClient, new object[] { view });
}
}
I place PhotonNetwork.automaticallySyncScene = true;
in the callback onJoinLobby, but nothing happened
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Photon - RPC Does Trigger but Does not Show Over Network :( 0 Answers
Best Solution for Multiplayer Shooting 1 Answer
Light.color Sync ? 1 Answer
Switching from Phothon Cloud to Server? 2 Answers