hello i am building a multiplayer game, and i have a problem with my client receiving information when he gets shot. i made a script that i attached to the player.
thank you in advance for your help.
[Command]
void CmdShoot(){
GameObject bullet = (GameObject)Instantiate (_bulletPrefab, _canon.position, _canon.rotation);
bullet.GetComponent<Rigidbody> ().velocity = bullet.transform.forward * _bulletSpeed;
NetworkServer.Spawn (bullet);
}
void OnCollisionEnter(Collision coll){
if (isLocalPlayer) {
if (coll.gameObject.tag == "bullet") {
Debug.Log ("hit");
isHit = true;
}
}
}
when i am on the host, everything works perfectly and every time i hit the host, i can see the debug.log in the inspector. but when i am on the client. the debug.log is not accurate the client only receives the information like 1/3 of the time, sometime it works sometime it doesn't. its like sometime the client doesn't find the gameobject tagged "bullet". Anyone got the same issue or knows how to fix that??