A NavigationPolygon is used in pathfinding to describe the traversable area that is safe from collision and other obstructions, assuming an agent's center position at zero radius.
</brief_description>
<description>
A NavigationPolygon is used in pathfinding to describe the traversable area that is safe from collision and other obstructions, assuming an agent's center position at zero radius. The mesh data can be created and baked to polygons with the [NavigationMeshGenerator] by drawing outlines in the Editor, or defining outlines by script, or by parsing source geometry from the [SceneTree]. The mesh data can also be created without outlines and baking by adding the required arrays of vertices and polygon indices more manually and calling [method commit_changes] afterwards.
When doing procedual changes a call to [method commit_changes] is required to apply all the made changes and to synchronize the changes with the [NavigationServer2D].
In scripts there are two more manual ways to create navigation polygons. Either by using the [method add_outline] method and baking with the [NavigationMeshGenerator], or using the methods [method set_vertices] and [method set_polygons] directly.
Using [method add_outline]:
[codeblock]
var new_navigation_polygon = NavigationPolygon.new()
Appends a [PoolVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use.
Adds a [PoolVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position. You have to call [method make_polygons_from_outlines] in order for this array to be converted to polygons that the engine will use.
Returns the array of baked outlines. The baked outlines are the result of a finished [NavigationMeshGenerator] baking process and primarily used for debugging purposes.
Sets the array of baked outlines. The baked outlines are the result of a finished [NavigationMeshGenerator] baking process and primarily used for debugging purposes.
Sets the vertices that need to be indexed with the [method add_polygon] or [method set_polygons] methods. When finished changing the navigation polygon call [method commit_changes] in order to synchronize the changes with the [Navigation2DServer].
The physics layers to scan for static colliders. Only used when [member geometry_parsed_geometry_type] is [constant PARSED_GEOMETRY_STATIC_COLLIDERS] or [constant PARSED_GEOMETRY_BOTH].
The name of the group to scan for geometry. Only used when [member geometry_source_geometry_mode] is [constant SOURCE_GEOMETRY_GROUPS_WITH_CHILDREN] or [constant SOURCE_GEOMETRY_GROUPS_EXPLICIT].
Filling rule for baking polygons that defines in complex polygons which polygon sub-regions will be considered inside a given polygon, and which sub-regions will not, aka what is a hole.
Parses mesh instances and other visual shapes as geometry. This includes [MeshInstance2D], [MultiMeshInstance2D], [Polygon2D], and [TileMap] (first TileMapLayer only) nodes.
Parses [StaticBody2D], and [TileMap] (first TileMapLayer only) colliders as geometry. The collider should be in any of the layers specified by [member geometry_collision_mask].
Squaring is applied uniformally at all joins where the internal join angle is less that 90 degrees. The squared edge will be at exactly the offset distance from the join vertex.
Creates mitered joins such that the line of junction bisects the angle. To avoid narrow angled joins producing excessively long and narrow spikes mitered joins are automatically squared when they exceed a given maximum miter distance relative to the offset distance.