void OnCollisionEnter(Collision other) { if (other.gameObject.tag != "Barrel") { ArmourPlate armourPlate = other.gameObject.GetComponent <ArmourPlate>(); if (armourPlate) { armourPlate.Hit(damage); } } }
void OnCollisionEnter(Collision other) { if (other.gameObject.tag != "Barrel") { Instantiate(explosionEffect, transform.position, transform.rotation); foreach (Collider nearbyObject in Physics.OverlapSphere(transform.position, blastRadius)) { ArmourPlate armourPlate = nearbyObject.GetComponent <ArmourPlate>(); if (armourPlate) { armourPlate.Hit(explosionForce); } Rigidbody rigidbody = nearbyObject.GetComponent <Rigidbody>(); if (rigidbody) { rigidbody.AddExplosionForce(explosionForce, transform.position, blastRadius); } } Destroy(gameObject); } }