- Home /
Question by
nonlin · Feb 04, 2015 at 01:52 PM ·
photonmultiplayer-networkinglagdeath
Network lag Causes enemy player to die twice.
Basically if a person can shoot faster than Photon can report back that the target has died the shooter gets an extra kill as a result of not knowing soon enough that the player has died.
Here is the code I use and I make sure to check the targets health which doesn't seem to matter because again if they can shoot faster than the network can resolve it would seem to allow them to stack a few extra kills. I'm sure this is a known issue but as my first go of it I'm not sure how to address this.
void FixedUpdate(){
if (shooting) {
shooting = false;
RaycastHit hit;
if(Physics.Raycast(transform.position, transform.forward, out hit, 50f)){
if(hit.transform.tag == "Player"){
if(hit.transform.GetComponent<PlayerNetworkMover>().GetHealth() > 0){
//Tell all we shot a player and call the RPC function GetShot passing damage runs on person shooting
hit.transform.GetComponent<PhotonView>().RPC ("GetShot", PhotonTargets.All, damage, PhotonNetwork.player);
Debug.Log ("<color=red>Target Health</color> " + hit.transform.GetComponent<PlayerNetworkMover>().GetHealth());
}
}
impacts[currentImpact].transform.position = hit.point;
impacts[currentImpact].GetComponent<ParticleSystem>().Emit(1);
//impactHole[currentImpact].transform.position = hit.point;
//impacts[currentImpact].GetComponent<ParticleSystem>().Emit(1);
if(++currentImpact >= maxImpacts){
currentImpact = 0;
}
}
}
}
Comment