System.Nullable<Vector3> GetRandomPoint()
System.Nullable<Vector3> GetRandomPoint( BBox box )
System.Nullable<Vector3> GetRandomPoint( Vector3 position, float radius )

robot_2Generated
code_blocksInput

Description

The GetRandomPoint method of the NavMesh class attempts to find a random point on the navigation mesh. This method returns a nullable Vector3, which represents the coordinates of the random point if one is found. If no valid point can be found, the method returns null.

Usage

To use the GetRandomPoint method, ensure that the navigation mesh is properly generated and enabled. Call the method on an instance of the NavMesh class to retrieve a random point. Check if the result is not null before using the returned Vector3 value.

Example

// Example of using GetRandomPoint
NavMesh navMesh = new NavMesh();

// Ensure the nav mesh is enabled and generated
if (navMesh.IsEnabled && !navMesh.IsDirty)
{
    Vector3? randomPoint = navMesh.GetRandomPoint();
    
    if (randomPoint.HasValue)
    {
        Vector3 point = randomPoint.Value;
        // Use the point for navigation or other purposes
    }
    else
    {
        // Handle the case where no point was found
    }
}