I’m still somewhat new to Unity and have been wrestling with this problem for a several days now. I am trying to send an array of values from the master client to any other client that joins using RPC functions. Basically, if the player is the Master client, createMaze is called and the value of rem_walls is set. I can see in the viewport when running the game that this is true. All other clients call the function createMaze2() which uses an RPC call to the Master to request the value for rem_walls, and the Master client sends this value back. However, for whatever reason, the value of rem_walls that is being sent is not the updated value of rem_walls. Hopefully the code below will make things more clear. Basically, in send_info() rem_walls is always empty, despite the fact that the variable has been updated and reflects this update when I check it in the viewport. Any help would be greatly appreciated.
public void createMaze2(){
//List<Vector3Int> to_rem;
initMaze ();
//PhotonView photonView = PhotonView.Get (this);
if (!PhotonNetwork.isMasterClient) {
this.photonView.RPC ("send_info", PhotonTargets.MasterClient, PhotonNetwork.player);
}
}
[PunRPC]
void send_info(PhotonPlayer plyr){
if (PhotonNetwork.isMasterClient) {
Debug.Log ("sending info");
//PhotonView photonView = PhotonView.Get (this);
Debug.Log (this.rem_walls);
Debug.Log (this.rem_walls.Count);
int[] ai = this.rem_walls.ToArray ();
this.photonView.RPC ("get_info", plyr, ai);
} else {
Debug.Log ("something is wrong");
}
}
[PunRPC]
void get_info(int [] x){
Debug.Log ("getting info");
Debug.Log (x);
rem_walls =new List<int>( x);
Debug.Log (x.Length);
for (int i = 0; i < x.Length; i=i+3) {
Debug.Log (i);
Destroy (Walls [x[i+2], x*, x[i+1]].gameObject);*
-
}*
-
}*
-
public void createMaze () {*
-
rem_walls.Add(1);*
-
}*