private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag(tagToCollide)) { HealthManager hp = collision.GetComponent <HealthManager>(); if (hp != null) { hp.AddShield(barrierHealth); Destroy(gameObject); } } }