protected RuntimeWaypoint FindNearestReachableWaypoint(Vector3 position)
        {
            var orderedWaypoints = waypoints.GetWaypointsOrderedByProximity(position);

            for (var i = 0; i < orderedWaypoints.Length; i++)
            {
                var wp = orderedWaypoints[i];

                if (PhysicsExtensions.CheckSightBetweenTwoPositions(position, wp.position, ~layersToIgnoreInSightTest))
                {
                    if (debugReachabilityTest)
                    {
                        Debug.DrawLine(position, wp.position, Color.green);
                    }

                    return(wp);
                }
                else if (debugReachabilityTest)
                {
                    Debug.DrawLine(position, wp.position, Color.red);
                }
            }

            return(null);
        }