My player gets 'frozen' in place

I think there might be something wrong…?
Because there is always a target (either set with inspector, or as part of the Attack(CombatTarget combatTarget) lines, once the player is in range, the Stop() method is called every frame. Even if clicking for a normal move. No goot!
My solution was to simply add a line that clears the target after Stop() is called, freeing the player to move normally.

private void Update()
        {
            if (target == null) return;
            CheckDistanceAndMove();   //this is locking the player in place.        
        }

        private void CheckDistanceAndMove()
        {
            bool isInRange = (Vector3.Distance(target.position, transform.position) < weaponRange);
            if (target !=null && !isInRange)
            {
                GetComponent<Mover>().MoveToDestination(target.position);
            }
            else
            {
                GetComponent<Mover>().Stop();
                target = null;
            }
        }

        public void Attack(CombatTarget combatTarget)
        {
            target = combatTarget.transform;
            Debug.Log("have at you");
        }

This is still early in the process. Once we get to the ActionScheduler, clicking to Move will automatically clear the Fighter’s target through the IAction interface.

thanks!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms