private void OnTriggerEnter2D(Collider2D other) { DamDealer damageDealer = other.gameObject.GetComponent <DamDealer>(); if (!damageDealer) { return; } ProcessHit(damageDealer); }
private void ProcessHit(DamDealer damageDealer) { health -= damageDealer.GetDamage(); damageDealer.Hit(); if (health <= 0) { Die(); } else { GameObject hit = Instantiate(hitVFX, transform.position, transform.rotation); Destroy(hit, durationOfHit); AudioSource.PlayClipAtPoint(hitSound, Camera.main.transform.position, hitSoundVolume); } }