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. 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() var new_navigation_polygon_outline = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)]) new_navigation_polygon.add_outline(new_navigation_polygon_outline) NavigationMeshGenerator.bake_2d_from_source_geometry_data(new_navigation_polygon, NavigationMeshSourceGeometryData2D.new()); $NavigationRegion2D.navigation_polygon = new_navigation_polygon [/codeblock] Using [method add_polygon] and indices of the vertices array. [codeblock] var new_navigation_polygon = NavigationPolygon.new() var new_navigation_polygon_vertices = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)]) new_navigation_polygon.vertices = new_navigation_polygon_vertices var new_navigation_polygon_polygon_indices = PoolIntArray([0, 1, 2, 3]) new_navigation_polygon.add_polygon(new_navigation_polygon_polygon_indices) new_navigation_polygon.commit_changes() $NavigationRegion2D.navigation_polygon = new_navigation_polygon [/codeblock] https://github.com/Relintai/pandemonium_demo_projects/tree/master/2d/navigation $DOCS_URL/tutorials/navigation/navigation_using_navigationmeshes.md 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. Adds a polygon using the indices of the vertices you get when calling [method get_vertices]. Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them. Clears the array of polygons, but it doesn't clear the array of outlines and vertices. Applies all changes to vertices and polygons and synchronizes with the [NavigationServer2D]. Returns the array of baked outlines. The baked outlines are the result of a finished [NavigationMeshGenerator] baking process and primarily used for debugging purposes. Returns whether or not the specified layer of the [member geometry_collision_mask] is enabled, given a [param layer_number] between 1 and 32. Returns a [PoolVector2Array] containing the vertices of an outline that was created in the editor or by script. Returns the number of outlines that were created in the editor or by script. Returns a [PoolIntArray] containing the indices of the vertices of a created polygon. Returns the number of polygons. Returns the array of polygons used by the internal navigation mesh. Each polygon array consists of the indices for the vertices that make the polygon. Returns a [PoolVector2Array] containing all the vertices being used to create the polygons. Creates polygons from the outlines added in the editor or by script. Removes an outline created in the editor or by script. Sets the array of baked outlines. The baked outlines are the result of a finished [NavigationMeshGenerator] baking process and primarily used for debugging purposes. Changes an outline created in the editor or by script. Sets the outline arrays. The outlines need to be baked to actual navigation mesh polygons by using the [NavigationMeshGenerator]. Sets the navigation mesh polygons. Each polygon array needs to consist of the indices for the vertices that make the polygon. 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 distance to erode/shrink the traversable area from obstructions when baking polygons. The cell size used to rasterize the navigation mesh vertices. Must match with the cell size on the navigation map. 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]. Determines which type of nodes will be parsed as geometry. See [enum ParsedGeometryType] for possible values. The source of the geometry used when baking. See [enum SourceGeometryMode] for possible values. 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]. The [enum OffsettingJoinType] used for joins when offsetting the bake polygons by [member agent_radius]. 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]. Both [constant PARSED_GEOMETRY_MESH_INSTANCES] and [constant PARSED_GEOMETRY_STATIC_COLLIDERS]. Represents the size of the [enum ParsedGeometryType] enum. Scans the child nodes of the root node recursively for geometry. Scans nodes in a group and their child nodes recursively for geometry. The group is specified by [member geometry_source_group_name]. Uses nodes in a group for geometry. The group is specified by [member geometry_source_group_name]. Represents the size of the [enum SourceGeometryMode] enum. Only odd numbered sub-regions are filled Only non-zero sub-regions are filled Only sub-regions with winding counts greater zero are filled. Only sub-regions with winding counts smaller zero are filled. Represents the size of the [enum PolygonFillRule] enum. 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. Rounding is applied to all joins that have convex external angles and the exact offset distance from the join vertex is maintained. 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. Represents the size of the [enum OffsettingJoinType] enum.