public void EngageTarget(Transform target) { float distanceToTarget = Vector2.Distance(transform.position, target.position); if (distanceToTarget <= attackRange) { if (timeSinceLastAttack >= attackInterval) { CheckAttackDirection(target); isAttacking = true; timeSinceLastAttack = 0; animator.SetTrigger("attack"); mover.rb.velocity = new Vector2(0, 0); } } else { mover.MoveToTarget(target.position); } }