void OnTriggerEnter2D(Collider2D theObject) { //if an enemy hits the attack area it is destroyed if (theObject.CompareTag(with)) { theObject.gameObject.GetComponent <Health> ().DealDamage(damageAmount); staminaBar.attack(); } }