Another script for stopattacking

hei. is it any downside with putting “stopattack” in mover insteed? seems more logical

 public class Mover : MonoBehaviour, IAction

        Ray _lastRay;

        private NavMeshAgent _navMeshAgent;
        private Animator _animator;
        private Camera _camera;
        private ActionScheduler _actionScheduler;

        // Start is called before the first frame update
        void Start()
            _navMeshAgent = GetComponent<NavMeshAgent>();
            _navMeshAgent.speed = 5.66f;
            _navMeshAgent.acceleration = 1000;
            _navMeshAgent.angularSpeed = 4000;
            _navMeshAgent.radius = 0.3f;
            _actionScheduler = GetComponent<ActionScheduler>();

            _animator = GetComponent<Animator>();
            _camera = Camera.main;

        // Update is called once per frame
        void Update()
        void UpdateAnimation()
            _animator.SetFloat("ForwardSpeed", transform.InverseTransformDirection(_navMeshAgent.velocity).z);

        public void StartMoveAction(Vector3 destination)
        public void Cancel()
            _navMeshAgent.isStopped = true;

        public void MoveTo(Vector3 destination)
            _navMeshAgent.destination = destination;
            _navMeshAgent.isStopped = false;

here is my code. its working as it should

If the Animator is NOT attacking, then the stopAttacking trigger will be set the next time that the Fighter attacks, meaning that the attack will immediately fall out of attack.

This can, of course, be remedied by resetting the trigger immediately before attacking, but it’s something to be aware of.

Personally, it feels to me like StopAttacking should be in Fighter.Cancel(), because it’s Fighter’s responsibility to manage attacking.

Privacy & Terms