Example #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        DamageControl damageCtrl = other.GetComponent <DamageControl>();

        if (damageCtrl != null)
        {
            damageCtrl.ChangeHealth(damage);
        }
    }
Example #2
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        DamageControl damageCtrl = other.collider.GetComponent <DamageControl>();

        if (damageCtrl != null)
        {
            damageCtrl.ChangeHealth(damage);
            Destroy(gameObject);
        }
    }