public void Explosion() { PlaySFX(_clipShellExplosion); //get all the tanks caught in the explosion Collider[] allCollider = Physics.OverlapSphere(transform.position, _explosionRadius, _explosionMask); //destroy the shell GameObject shellExplosion = Instantiate(_shellExplosion, transform.position, transform.rotation); Destroy(gameObject); Destroy(shellExplosion, 1); //loop through the collider to apply force and damage foreach (Collider collider in allCollider) { Rigidbody trbody = collider.GetComponent <Rigidbody>(); if (trbody == null) { continue; } if (collider.GetComponent <FriendlyUnit>() != null) { FriendlyUnit fu = collider.GetComponent <FriendlyUnit>(); fu.Death(); } if (collider.GetComponent <EnemyUnit>() != null) { EnemyUnit eu = collider.GetComponent <EnemyUnit>(); eu.Death(); } } }