//************************************************** private void DealDamage(GameObject target, float damage) { // Hit nothing or environment if (!target || target.layer == LayerMask.NameToLayer("Environment")) { return; } // Make sure target was not already damaged if (!hitTargets.Contains(target)) { // Save target (root gameobject) hitTargets.Add(target); HealthBase targetHealth = target.GetComponent <HealthBase>(); if (targetHealth) { if (!targetHealth.IsDead()) { // Damage target & play hitsounds if (weaponBase) { //weaponBase.PlayHitSounds(targetHealth.ReceiveDamage(damage)); bool lethalDmg = targetHealth.ReceiveDamage(damage); if (hitTargets.Count == 1) { weaponBase.PlayHitSounds(lethalDmg); // Play hitsound only once } } } } } }
//************************************************** private void DealDamage(GameObject target, float damage) { HealthBase targetHealth = target.GetComponent <HealthBase>(); if (targetHealth) { if (!targetHealth.IsDead()) { // Damage target & play hitsounds PlayHitSounds(targetHealth.ReceiveDamage(damage)); } } }