Пример #1
0
 private int ChooseWaypointNearest()
 {
     if (target != null)
     {
         WaypointInfo aux = waypoints.MinBy(x => Vector2Extend.DistancePow2(target.position, x.target.position));
         return(aux.ID);
     }
     return(-1);
 }
Пример #2
0
        private void Update()
        {
            if (_active && target && destination)
            {
                Vector2 dir = Vector2Extend.Direction(target.position, destination.position);
                _movementInterface?.SetDirection(dir);

                float distance = Vector2Extend.DistancePow2(target.position, destination.position);
                if (distance <= mindDistanceForStop)
                {
                    Stop();
                }
            }
        }