navcat docs
    Preparing search index...

    Function findRandomPointAroundCircle

    • Finds a random point around a center position on the navigation mesh. The location is not exactly constrained by the circle, but it limits the visited polygons.

      Uses Dijkstra-like search to explore reachable polygons within the circle, then selects a random polygon weighted by area, and finally generates a random point within that polygon. This function is using reservoir sampling and can fail in rare occurences even if there is an actual solution.

      Parameters

      • navMesh: NavMesh

        The navigation mesh

      • startNodeRef: number

        Reference to the polygon to start the search from

      • position: Vec3

        Center position of the search circle

      • maxRadius: number

        Maximum radius of the search circle

      • filter: QueryFilter

        Query filter to apply to polygons

      • rand: () => number

        Function that returns random values [0,1]

      Returns FindRandomPointAroundCircleResult

      The result object with success flag, random point, and polygon reference