NavigationMesh

    A mesh to approximate the walkable areas and obstacles.

    A navigation mesh is a collection of polygons that define which areas of an environment are traversable to aid agents in pathfinding through complicated spaces.

    Tutorials

    Methods

    void

    ( PoolIntArray polygon )

    void

    ( )

    void

    create_from_mesh ( mesh )

    bool

    ( int bit ) const

    get_polygon ( idx )

    int

    ( ) const

    PoolVector3Array

    ( ) const

    void

    set_collision_mask_bit ( bit, bool value )

    void

    ( PoolVector3Array vertices )

    enum SamplePartitionType:

    • SAMPLE_PARTITION_WATERSHED = 0 —- Watershed partitioning. Generally the best choice if you precompute the navigation mesh, use this if you have large open areas.

    • SAMPLE_PARTITION_MONOTONE = 1 —- Monotone partitioning. Use this if you want fast navigation mesh generation.

    • SAMPLE_PARTITION_LAYERS = 2 —- Layer partitioning. Good choice to use for tiled navigation mesh with medium and small sized tiles.


    enum ParsedGeometryType:

    • PARSED_GEOMETRY_MESH_INSTANCES = 0 —- Parses mesh instances as geometry. This includes MeshInstance, , and GridMap nodes.

    • PARSED_GEOMETRY_STATIC_COLLIDERS = 1 —- Parses colliders as geometry. The collider should be in any of the layers specified by geometry_collision_mask.

    • PARSED_GEOMETRY_BOTH = 2 —- Both and PARSED_GEOMETRY_STATIC_COLLIDERS.

    • PARSED_GEOMETRY_MAX = 3 —- Represents the size of the enum.


    enum SourceGeometryMode:

    • SOURCE_GEOMETRY_GROUPS_WITH_CHILDREN = 1 —- Scans nodes in a group and their child nodes recursively for geometry. The group is specified by geometry_source_group_name.

    • SOURCE_GEOMETRY_GROUPS_EXPLICIT = 2 —- Uses nodes in a group for geometry. The group is specified by .

    • SOURCE_GEOMETRY_MAX = 3 —- Represents the size of the SourceGeometryMode enum.

    Property Descriptions

    Default

    1.5

    Setter

    set_agent_height(value)

    Getter

    get_agent_height()

    The minimum floor to ceiling height that will still allow the floor area to be considered walkable.

    Note: While baking, this value will be rounded up to the nearest multiple of .


    Default

    0.25

    Setter

    set_agent_max_climb(value)

    Getter

    get_agent_max_climb()

    The minimum ledge height that is considered to still be traversable.

    Note: While baking, this value will be rounded down to the nearest multiple of .


    Default

    45.0

    Setter

    set_agent_max_slope(value)

    Getter

    get_agent_max_slope()

    The maximum slope that is considered walkable, in degrees.


    • agent_radius

    Default

    0.5

    Setter

    set_agent_radius(value)

    Getter

    get_agent_radius()

    The distance to erode/shrink the walkable area of the heightfield away from obstructions.

    Note: While baking, this value will be rounded up to the nearest multiple of cell_size.


    • cell_height

    Default

    0.25

    Setter

    set_cell_height(value)

    Getter

    get_cell_height()

    The Y axis cell size to use for fields.


    Default

    0.25

    Setter

    set_cell_size(value)

    Getter

    get_cell_size()

    The XZ plane cell size to use for fields.


    • detail_sample_distance

    The sampling distance to use when generating the detail mesh, in cell unit.


    • float detail_sample_max_error

    Default

    1.0

    Setter

    set_detail_sample_max_error(value)

    Getter

    get_detail_sample_max_error()

    The maximum distance the detail mesh surface should deviate from heightfield, in cell unit.


    • edge_max_error

    Default

    1.3

    Setter

    set_edge_max_error(value)

    Getter

    get_edge_max_error()

    The maximum distance a simplfied contour’s border edges should deviate the original raw contour.


    Default

    12.0

    Setter

    set_edge_max_length(value)

    Getter

    get_edge_max_length()

    The maximum allowed length for contour edges along the border of the mesh.

    Note: While baking, this value will be rounded up to the nearest multiple of .


    • AABB filter_baking_aabb

    Default

    AABB( 0, 0, 0, 0, 0, 0 )

    Setter

    set_filter_baking_aabb(value)

    Getter

    get_filter_baking_aabb()

    If the baking has a volume the navigation mesh baking will be restricted to its enclosing area.


    Default

    Vector3( 0, 0, 0 )

    set_filter_baking_aabb_offset(value)

    Getter

    get_filter_baking_aabb_offset()

    The position offset applied to the AABB.


    • filter_ledge_spans

    Default

    false

    Setter

    set_filter_ledge_spans(value)

    Getter

    get_filter_ledge_spans()

    If , marks spans that are ledges as non-walkable.


    Default

    false

    Setter

    set_filter_low_hanging_obstacles(value)

    Getter

    get_filter_low_hanging_obstacles()

    If true, marks non-walkable spans as walkable if their maximum is within agent_max_climb of a walkable neighbor.


    • filter_walkable_low_height_spans

    If true, marks walkable spans as not walkable if the clearance above the span is less than agent_height.


    • geometry_collision_mask

    Default

    4294967295

    Setter

    set_collision_mask(value)

    Getter

    get_collision_mask()

    The physics layers to scan for static colliders.

    Only used when geometry_parsed_geometry_type is or PARSED_GEOMETRY_BOTH.


    • geometry_parsed_geometry_type

    Default

    0

    Setter

    set_parsed_geometry_type(value)

    Getter

    get_parsed_geometry_type()

    Determines which type of nodes will be parsed as geometry. See ParsedGeometryType for possible values.


    • geometry_source_geometry_mode

    Default

    0

    Setter

    set_source_geometry_mode(value)

    Getter

    get_source_geometry_mode()

    The source of the geometry used when baking. See SourceGeometryMode for possible values.


    • geometry_source_group_name

    Default

    “navmesh”

    Setter

    set_source_group_name(value)

    Getter

    get_source_group_name()

    The name of the group to scan for geometry.

    Only used when geometry_source_geometry_mode is or SOURCE_GEOMETRY_GROUPS_EXPLICIT.


    • polygon_verts_per_poly

    Default

    6.0

    Setter

    set_verts_per_poly(value)

    Getter

    get_verts_per_poly()

    The maximum number of vertices allowed for polygons generated during the contour to polygon conversion process.


    Default

    20.0

    Setter

    set_region_merge_size(value)

    Getter

    get_region_merge_size()

    Any regions with a size smaller than this will be merged with larger regions if possible.

    Note: This value will be squared to calculate the number of cells. For example, a value of 20 will set the number of cells to 400.


    • region_min_size

    Default

    2.0

    Setter

    set_region_min_size(value)

    Getter

    get_region_min_size()

    The minimum size of a region for it to be created.

    Note: This value will be squared to calculate the minimum number of cells allowed to form isolated island areas. For example, a value of 8 will set the number of cells to 64.


    Partitioning algorithm for creating the navigation mesh polys. See for possible values.

    • void add_polygon ( polygon )

    Adds a polygon using the indices of the vertices you get when calling get_vertices.


    • void clear_polygons ( )

    Clears the array of polygons, but it doesn’t clear the array of vertices.


    • void create_from_mesh ( mesh )

    Initializes the navigation mesh by setting the vertices and indices according to a Mesh.


    • get_collision_mask_bit ( int bit ) const

    Returns whether the specified bit of the is set.


    Returns a PoolIntArray containing the indices of the vertices of a created polygon.


    • get_polygon_count ( ) const

    Returns the number of polygons in the navigation mesh.


    Returns a containing all the vertices being used to create the polygons.


    If value is true, sets the specified bit in the geometry_collision_mask.


    • void set_vertices ( vertices )

    Sets the vertices that can be then indexed to create polygons with the add_polygon method.