- Home /
Networking: Players being "Perma-hit"
Hey Unity Answers,
I'm working on an online-deathmatch type game and have an issue where players are getting hit, and don't stop getting hit.
What that means is, when a player is hit by another ONCE, the animations of him getting hit (camera shake, etc.) play and his health goes down, but these actions don't stop. His health still keeps going down even when he's no-longer getting hit.
This issue only happens when there are 3 or more players connected, so I'm pretty sure it's an issue with networking.
Here's the code for the player's health box getting hit:
[RPC] public void getHit(float amount){
if (offlineMode == false){
log ("I'm Hit!");
if (health){
health.loseHealth (amount);
}
if (networkView.isMine == false){
networkView.RPC ("getHit", RPCMode.OthersBuffered, amount);
}
}else{
log ("I'm Hit!");
health.loseHealth (amount);
}
}
void log(string s){
Debug.Log (s);
}
and here's the code for the player's weapon telling the hitbox to get hit:
void OnTriggerEnter(Collider other){
if (other.tag == "PlayerTargetArea"){
Debug.Log("HIT SOMETHING!");
other.GetComponent<TargetAreaScript>().getHit (damage);
}
}
Anyone know what's up?
Thanks!
For some reason, the question was denied, so I posted it to the forums. Here's the forum complete with solution: http://forum.unity3d.com/threads/players-being-perma-hit.280632/#post-1851477
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Networking between projects: how to send ViewIDs? 1 Answer
Network how to send data/activate function 1 Answer
ClientRpc not called on Client 1 Answer