Client can damage host but not vice versa?
I'm learning how to make a simple fps multiplayer game with Unity's built in networking and I have this problem:
I am using raycasts to shoot, and for some reason, the client can damage the host and destroy him while the host can damage the client as well, but not destroy him. I have no clue what's going on haha any help would be AWESOME! Here's the shoot code: [Client] void CmdShoot() { RaycastHit _hit; if (Physics.Raycast(cam.transform.position, cam.transform.forward, out _hit, weapon.range, mask)) { if (_hit.collider.tag==PLAYER_TAG) { CmdPlayerShot(_hit.collider.name);
}
}
}
[Client]
void CmdPlayerShot (string _ID)
{
GameObject go = GameObject.Find(_ID);
go.GetComponent<PlayerMovement>().damage();
}
}
In the void CmdPlayerShot, I am calling to my player script which holds the function "damage" that lowers the variable "health" (Also in the player script) down by ten every time they get shot. I then have in my update (On player script):
if (health <=0)
{
Respawn();
}
Which calls a Respawn function which destroys the gameObject and respawns them in the scene. Sorry if this is a mouthfull haha I've been messing with this for hours now and can't seem to get it right.
Did you seem to fix the issue? I am having the exact same problem.
Believe it or not, I have still not yet figured it out haha
Your answer
Follow this Question
Related Questions
Raycast over Photon 0 Answers
Disable Damage Raycast? 1 Answer
Help with photon being used to make a mulitplayer fps 0 Answers
How do i fix a multiplayer fps health issue? 0 Answers
Raycast Weapon not cause damage 1 Answer