private void OnTriggerEnter2D(Collider2D other) { DamageControl damageCtrl = other.GetComponent <DamageControl>(); if (damageCtrl != null) { damageCtrl.ChangeHealth(damage); } }
private void OnCollisionEnter2D(Collision2D other) { DamageControl damageCtrl = other.collider.GetComponent <DamageControl>(); if (damageCtrl != null) { damageCtrl.ChangeHealth(damage); Destroy(gameObject); } }