private void Update() { lastAttackTime += Time.deltaTime; if (target == null) { return; } if (target.IsDead()) { target = null; return; } bool isInRangeToAttack = Vector3.Distance(transform.position, target.transform.position) < defaultWeaponRange; if (!isInRangeToAttack) { characterMover.MoveToAttack(target.transform.position); } else { characterMover.CancelAction(); AttackBehaviour(); } }