- Home /
Question by
dreal1220 · May 14, 2015 at 04:24 PM ·
camerainstantiatephoton
Photonview with 4 separate cameras
Hi,
I am trying to pass some active terrain data over the network so all clients will see the changes to the terrain. how would i go about this?
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?
PhotonView photonView;
void Start(){
photonView = PhotonView.Get(this);
}
void Update(){
PassNetworkData ();
}
[RPC]
public void CreateHole(){
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("CreateHole",PhotonTargets.All,null);
}
}
Comment