mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-29 12:52:07 +01:00
Grenades damage at player
Grenades now remove the correct damage
This commit is contained in:
@@ -109,8 +109,6 @@ public class Player : NetworkBehaviour
|
||||
}
|
||||
public void RemoveHealth(int value)
|
||||
{
|
||||
|
||||
|
||||
if (isAlive)
|
||||
{
|
||||
ShowHit();
|
||||
@@ -121,7 +119,6 @@ public class Player : NetworkBehaviour
|
||||
Die();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[ClientRpc]
|
||||
|
||||
@@ -37,8 +37,8 @@ public class Grenade : MonoBehaviour
|
||||
Collider[] colliders = Physics.OverlapSphere(transform.position, weapon.GrenadeRadius);
|
||||
// Iterate over all colliders found in radius
|
||||
foreach(Collider nearbyObject in colliders) {
|
||||
// Check if nearby object is a Player
|
||||
if (nearbyObject.transform.gameObject.GetComponent<Player>()) {
|
||||
// Check if nearby object is a Player and if Collider is not a CharacterController (can be changed to CapsuleCollider)
|
||||
if (nearbyObject.transform.gameObject.GetComponent<Player>() && nearbyObject.GetType() != typeof(UnityEngine.CharacterController)) {
|
||||
// Remove health from player
|
||||
nearbyObject.transform.gameObject.GetComponent<Player>().RemoveHealth(weapon.Damage);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user