void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Attacker") { AttackerHealth attackerHealth = other.GetComponent <AttackerHealth>(); if (attackerHealth != null) { attackerHealth.DealDamage(); Destroy(gameObject); } } }
public void strikeCurrentInvader(float damage) { if (!currentInvaderTarget) { return; } AttackerHealth health = currentInvaderTarget.GetComponent <AttackerHealth>(); if (health) { health.DealDamage(damage); } }