RPC with no function parameter?

Options
Hi,
I am trying to pass some active terrain data over the network so both clients will see the changes to the terrain. how would i go about this? I have a function that has no parameters that i am passing to the RPC function and i tried everything but no change. I am using pun+. ;)
[RPC]

PhotonView photonView;
void Start(){
photonView =  PhotonView.Get(this);

}
void Update(){
PassNetworkData ();

}
	public void CreateRock(){

		
		 x = (int)Mathf.Lerp(0, (int)xRes, Mathf.InverseLerp(0, this.tData.size.x, Globals.fireParticleEmitter.transform.position.x ));
		 z = (int)Mathf.Lerp(0, (int)yRes, Mathf.InverseLerp(0, this.tData.size.z, Globals.fireParticleEmitter.transform.position.z ));
		x = (int)Mathf.Clamp(x, cratertex.width/2, xRes-cratertex.width/2);
		z = (int)Mathf.Clamp(z, cratertex.height/2, yRes-cratertex.height/2);
		float[,] areaT= tData.GetHeights(x-cratertex.width/2, z-cratertex.height/2, cratertex.width, cratertex.height);
		for (int i = 0; i < cratertex.height; i++) {
			for (int j = 0; j < cratertex.width; j++) {
				areaT [i,j] = areaT [i,j] - craterData[i+cratertex.width*j].a*explosionStrength ;
			}
		}
		//if(Inventory.canUseRock || Player.isTrueFred || Player.isTrueBrom){		
		tData.SetHeights(x-cratertex.width / 2, z-cratertex.height / 2, areaT);	
		//}

	}

	public void PassNetworkData(){

		photonView.RPC("CreateRock",PhotonTargets.All,null);

	}

}


Comments

  • Tobias
    Options
    The solution depends a lot on what you plan to do: How much data is this going to be? A lot? For lots of players or just two?
    CreateRock needs to have a "RPC" attribute:
    [RPC]
    public void CreateRock() {
    
  • dreal
    Options
    I added the [RPC] before the function but it still didn't work. I have four different players in the scene, each with there own camera. I want all the cameras to see the same things happening in the scene. Example: One of the clients fire a rock and it hits the terrain, creating a hole and every other camera will see that hole. Should i use the photon observer component? Is it not working because all the cameras are separate so they are not syncing with each other?
  • Tobias
    Options
    Please do the Marco Polo Tutorial. It should teach you the basics needed to solve this:
    http://doc.exitgames.com/en/pun/current ... marco-polo