public void OnTriggerEnter2D(Collider2D col) { if (!col.isTrigger) { if (col.CompareTag(targetTag)) { I_Killable killable = col.GetComponentInParent <I_Killable>(); if (!killable.IsInvicible()) { float targetLife = killable.GetLife(); killable.TakeDamage(damage); damage -= targetLife; float coef = damage / maxDamage; transform.localScale = startScale * coef; if (damage <= 0) { DestroyBullet(); } } } else if (col.CompareTag("Environment")) { DestroyBullet(); } } }
public void OnTriggerEnter2D(Collider2D col) { if (!col.isTrigger) { if (col.CompareTag(targetTag)) { I_Killable killable = col.GetComponentInParent <I_Killable>(); if (!killable.IsInvicible()) { killable.TakeDamage(damage); } DestroyBullet(); } else if (col.CompareTag("Environment")) { DestroyBullet(); } } }