/// <summary>
        /// Initialize an Agent so that it has all necessary parameters for using the engine.
        /// </summary>
        /// <param name="agent"></param>
        public void Init(Agent agent)
        {
            _agent          = agent;
            _motion         = agent.Motion;
            _transform      = agent.transform;
            _agentAnimation = agent.AgentAnimation;

            _lastMoveAroundDestination = agent.transform.position;

            if (agent.GetComponent <IAstarAI>() != null)
            {
                _starAi = agent.GetComponent <IAstarAI>();
            }
            else
            {
                _starAi        = agent.gameObject.AddComponent <AIPath>();
                _starAi.height = 2f;
                _starAi.radius = 0.5f;
            }

            if (!agent.gameObject.GetComponent <Seeker>())
            {
                agent.gameObject.AddComponent <Seeker>();
            }
            if (!agent.gameObject.GetComponent <FunnelModifier>())
            {
                agent.gameObject.AddComponent <FunnelModifier>();
            }
            if (!agent.gameObject.GetComponent <RVOController>())
            {
                agent.gameObject.AddComponent <RVOController>();
            }

            if (!GameObject.FindObjectOfType <RVOSimulator>())
            {
                new GameObject("RVOSimulator").AddComponent <RVOSimulator>();
                Debug.Log("A new GameObject of type RVOSimulator has been created");
            }
        }
        /// <summary>
        /// This method gets called every Agent's update. Once every frame by default.
        /// </summary>
        public void Update()
        {
            if (_animation && AnimationMode == AnimationMode.Legacy && !_animation.isPlaying)
            {
                Animate(AnimationState.Idling);
            }

            if (_animator && AnimationMode == AnimationMode.Mecanim && _applyRootMotion)
            {
                var remainingDistance = Vector3.Distance(_agent.transform.position, _agent.Target.position);
                var stoppingDistance  = 0f;
                var desiredVelocity   = Vector3.zero;
#if ASTAR_EXISTS
                desiredVelocity = _agent.Motion.Type == MotionEngine.NavMesh
                                        ? _agent.GetComponent <NavMeshAgent>().desiredVelocity
                                        : _agent.Motion.Type == MotionEngine.Astar
                                                ? _agent.GetComponent <IAstarAI>().desiredVelocity : Vector3.zero;
                stoppingDistance = _agent.Motion.Type == MotionEngine.NavMesh
                                        ? _agent.GetComponent <NavMeshAgent>().stoppingDistance
                                        : _agent.Motion.Type == MotionEngine.Astar
                                                ? _agent.GetComponent <AIPath>().endReachedDistance : 0f;
#else
                desiredVelocity = _agent.Motion.Type == MotionEngine.NavMesh
                                        ? _agent.GetComponent <NavMeshAgent>().desiredVelocity : Vector3.zero;
                stoppingDistance = _agent.Motion.Type == MotionEngine.NavMesh
                                        ? _agent.GetComponent <NavMeshAgent>().stoppingDistance : 0f;
#endif
                if (remainingDistance > stoppingDistance)
                {
                    RootmotionMove(desiredVelocity);
                }
                else
                {
                    RootmotionMove(Vector3.zero);
                }

                _agent.transform.position = new Vector3(_animator.transform.position.x, _agent.transform.position.y, _animator.transform.position.z);
                _agent.transform.rotation = _animator.transform.rotation;
                if (_animator.transform.position.y != _agent.transform.position.y)
                {
                    _animator.transform.position += new Vector3(0, _agent.transform.position.y - _animator.transform.position.y, 0);
                }
            }
        }