Receiver client crashes after RCP

Options
Hello everyone,

I'm developing an RTS tactics game. There are only 2 players. I want to call a method ("setTurn()") on "Player" script after pressing the button "Pass turn".

Here is the method I call after pressing the button. It is inside the "Player" script:

public void turnPassed()
{
GetComponent<PhotonView>().RPC("setTurn", RpcTarget.All);
}

and setTurn() is (also inside "Player"):
(the method is longer, I just summarized it)

[PunRPC]
public void setTurno()
{
Debug.Log("settingTurn");
this.turno = !turno;
}

The one who presses the button is the masterClient. He also receives the call correctly. However, the other player freezes and crashes without showing the Debug.Log at the beginning of the method.

Player Gameobject is instantiated with PhotonNetwork.Instantiate (also tried PhotonNetwork.IntantiateRoomObject because I did not want anyone to own it). It is only instantiated by the masterClient. It has a PhotonView component on it and the "Player" component.

My unity version is 2018.3.6 and the PUN2 version is 2.23.

Any idea why this is happening?

Thank you in advanced!

Comments

  • Tobias
    Options
    The crash will be caused by the code you got in setTurno(). Everything else seems to work, as you say.

    The normal debug approach is to comment out most of the method (rendering it useless but not causing issues), then un-comment code in pieces you understand.

    The log at the beginning of the method may be missing, because the client crashed. For example, keep just this and comment out the rest.
  • Yes, you were totally right. I thought that Unity did not continue to the next line before printing the log. The client crashed just after the log but RCP was working perfectly.

    Thank you!