private void Attack() { float distance = Vector3.Distance(_target.transform.position, transform.position); Vector3 dir = (_target.transform.position - transform.position).normalized; float direction = Vector3.Dot(dir, transform.forward); if (distance <= 2.5f && direction > 0) { PlayerHealthBar eh = (PlayerHealthBar)_target.GetComponent("PlayerHealthBar"); eh.AddjustCurrentHealth(-10); } }