override protected void OnTriggerEnter2D(Collider2D otherCol) { if (attackedTags.Contains(otherCol.tag)) { //if it takes energy to inflict damage, don't run any of the hit code if (costsEnergy && energyCost > attackerParent.GetComponent <PlayerController>().CheckEnergy()) { return; } Hurtbox hurtbox = otherCol.GetComponent <Hurtbox>(); if (hurtbox != null && hurtbox.OnHit(this)) { OnAttackLand(hurtbox.GetParent(), hurtbox); } } }
virtual protected void OnTriggerEnter2D(Collider2D otherCol) { if (!ExtendedAttackCheck(otherCol)) { return; } if (attackedTags.Contains(otherCol.gameObject.tag)) { if (otherCol.GetComponent <Hurtbox>() == null) { return; } Hurtbox hurtbox = otherCol.GetComponent <Hurtbox>(); if (hurtbox.OnHit(this)) { OnAttackLand(hurtbox.GetParent(), hurtbox); } } }