public PointsOnSplineExtension.Waypoint GetClosestWaypointRight(ControllerStick controller, out float dist, out PointsOnSplineExtension lister)
        {
            dist   = 0;
            lister = null;
            if (ListToCheck.Length == 0)
            {
                return(null);
            }
            PointsOnSplineExtension.Waypoint closest = null;
            dist   = 0;
            lister = null;
            bool foundOne = false;

            for (int i = 0; i < ListToCheck.Length; i++)
            {
                if (ListToCheck[i] == null || !ListToCheck[i].gameObject.activeInHierarchy)
                {
                    continue;
                }
                PointsOnSplineExtension.Waypoint waypointToTest = ListToCheck[i].GetClosestWaypointRight(controller);
                if (waypointToTest == null)
                {
                    continue;
                }

                if (!foundOne)
                {
                    closest  = waypointToTest;
                    dist     = PointsOnSplineExtension.DistFromWayPoint(waypointToTest, controller);
                    lister   = ListToCheck[i];
                    foundOne = true;
                }
                else
                {
                    float distToTest = PointsOnSplineExtension.DistFromWayPoint(waypointToTest, controller);
                    if (distToTest < dist)
                    {
                        closest = waypointToTest;
                        dist    = distToTest;
                        lister  = ListToCheck[i];
                    }
                }
            }
            return(closest);
        }
 public PointsOnSplineExtension.Waypoint GetClosestWaypointBidirectionnal(ControllerStick controller, out float dist, out PointsOnSplineExtension lister)
 {
     dist   = 0;
     lister = null;
     if (ListToCheck.Length == 0)
     {
         return(null);
     }
     PointsOnSplineExtension.Waypoint closest = ListToCheck[0].GetClosestWaypointBidirectionnal(controller);
     dist   = PointsOnSplineExtension.DistFromWayPoint(closest, controller);
     lister = ListToCheck[0];
     for (int i = 1; i < ListToCheck.Length; i++)
     {
         PointsOnSplineExtension.Waypoint waypointToTest = ListToCheck[i].GetClosestWaypointBidirectionnal(controller);
         float distToTest = PointsOnSplineExtension.DistFromWayPoint(waypointToTest, controller);
         if (distToTest < dist)
         {
             closest = waypointToTest;
             dist    = distToTest;
             lister  = ListToCheck[i];
         }
     }
     return(closest);
 }