Привет помоги с рефакторингом 
namespace Pedestrian
{
    [RequireComponent(typeof(Animator))]
    [RequireComponent(typeof(NavMeshAgent))]
    public class PedestrianCharacter : MonoBehaviour
    {
        private List<Vector3> pointsPath = new List<Vector3>();

        private CreatorPathBot creatorPath;
        private Animator animator;
        private NavMeshAgent navMeshAgent;

        private Vector2 velocity;
        private Vector2 smoothDeltaPosition;
        private int currentTargetIndex;
        private Coroutine coroutine;
        public NavMeshAgent Agent { get => navMeshAgent; }

        public void Ini()
        {
            animator = GetComponent<Animator>();
            navMeshAgent = GetComponent<NavMeshAgent>();

            animator.applyRootMotion = true;
            navMeshAgent.updatePosition = false;
            navMeshAgent.updateRotation = true;

            creatorPath = new CreatorPathBot();

            pointsPath.AddRange(creatorPath.GetPathBot());

            if (coroutine == null)
            {
                coroutine = StartCoroutine(MoveToPoints());
            }
        }

        private void OnAnimatorMove()
        {
            var rootPosition = animator.rootPosition;
            rootPosition.y = navMeshAgent.nextPosition.y;
            transform.position = rootPosition;
            navMeshAgent.nextPosition = rootPosition;
        }

        private void Update()
        {
            UpdateAnimator();
            navMeshAgent.SetDestination(pointsPath[currentTargetIndex]);
        }

        private void UpdateAnimator()
        {
            var woridDeltaPosition = navMeshAgent.nextPosition - transform.position;
            woridDeltaPosition.y = 0;

            var deltaX = Vector3.Dot(transform.right, woridDeltaPosition);
            var deltaY = Vector3.Dot(transform.forward, woridDeltaPosition);
            var deltaPosition = new Vector2(deltaX,deltaY);

            var smooth = Mathf.Min(1, Time.deltaTime / 0.1f);
            smoothDeltaPosition = Vector2.Lerp(smoothDeltaPosition,deltaPosition,smooth);

            velocity = smoothDeltaPosition / Time.deltaTime;
            if (navMeshAgent.remainingDistance <= navMeshAgent.stoppingDistance)
            {
                velocity = Vector2.Lerp(
                    Vector2.zero, 
                    velocity,
                    navMeshAgent.remainingDistance / navMeshAgent.stoppingDistance);
            }

            var shouldMove = velocity.magnitude > 0.5f
               && navMeshAgent.remainingDistance > navMeshAgent.stoppingDistance;

            animator.SetFloat("speedPercent", velocity.magnitude);
            animator.SetBool("Move", shouldMove);

            var deltaMagnitude = woridDeltaPosition.magnitude;
            if (deltaMagnitude> navMeshAgent.radius/2f)
            {
                transform.position = Vector3.Lerp(animator.rootPosition, navMeshAgent.nextPosition,smooth);
            }
        }

        private IEnumerator MoveToPoints()
        {
            while(true)
            {
                yield return new WaitForSeconds(1f);

                if (Vector3.SqrMagnitude(transform.position - new Vector3(pointsPath[currentTargetIndex].x, 0, pointsPath[currentTargetIndex].z)) < 1)
                {
                    currentTargetIndex = (currentTargetIndex + 1) % pointsPath.Count;
                    navMeshAgent.SetDestination(pointsPath[currentTargetIndex]);
                }

            }  
        }
    }
}