private void OnTriggerEnter2D(Collider2D collision) { Attacker attacker = collision.gameObject.GetComponent <Attacker>(); if (attacker) { healthDisplay.DealDamage(attacker.GetAttackDamage()); Destroy(attacker.gameObject); } }
private void OnTriggerEnter2D(Collider2D collision) { GameObject otherObject = collision.gameObject; if (otherObject.GetComponent <Attacker>()) { HealthDisplay healthDisplay = FindObjectOfType <HealthDisplay>(); healthDisplay.DealDamage(defaultDamage); Destroy(otherObject); } }
void OnTriggerEnter2D(Collider2D collider) { healthDisplay.DealDamage(); }