:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/3.5/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/3.5/doc/classes/NavigationPolygon.xml. .. _class_NavigationPolygon: NavigationPolygon ================= **Inherits:** :ref:`Resource` **<** :ref:`Reference` **<** :ref:`Object` A node that has methods to draw outlines or use indices of vertices to create navigation polygons. Description ----------- There are two ways to create polygons. Either by using the :ref:`add_outline` method, or using the :ref:`add_polygon` method. Using :ref:`add_outline`: :: var polygon = NavigationPolygon.new() var outline = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)]) polygon.add_outline(outline) polygon.make_polygons_from_outlines() $NavigationPolygonInstance.navpoly = polygon Using :ref:`add_polygon` and indices of the vertices array. :: var polygon = NavigationPolygon.new() var vertices = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)]) polygon.set_vertices(vertices) var indices = PoolIntArray([0, 1, 2, 3]) polygon.add_polygon(indices) $NavigationPolygonInstance.navpoly = polygon Tutorials --------- - `2D Navigation Demo `__ Methods ------- +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_outline` **(** :ref:`PoolVector2Array` outline **)** | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_outline_at_index` **(** :ref:`PoolVector2Array` outline, :ref:`int` index **)** | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_polygon` **(** :ref:`PoolIntArray` polygon **)** | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear_outlines` **(** **)** | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear_polygons` **(** **)** | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`NavigationMesh` | :ref:`get_mesh` **(** **)** | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PoolVector2Array` | :ref:`get_outline` **(** :ref:`int` idx **)** |const| | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_outline_count` **(** **)** |const| | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PoolIntArray` | :ref:`get_polygon` **(** :ref:`int` idx **)** | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_polygon_count` **(** **)** |const| | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PoolVector2Array` | :ref:`get_vertices` **(** **)** |const| | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`make_polygons_from_outlines` **(** **)** | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`remove_outline` **(** :ref:`int` idx **)** | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_outline` **(** :ref:`int` idx, :ref:`PoolVector2Array` outline **)** | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_vertices` **(** :ref:`PoolVector2Array` vertices **)** | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Method Descriptions ------------------- .. _class_NavigationPolygon_method_add_outline: - void **add_outline** **(** :ref:`PoolVector2Array` outline **)** Appends a :ref:`PoolVector2Array` that contains the vertices of an outline to the internal array that contains all the outlines. You have to call :ref:`make_polygons_from_outlines` in order for this array to be converted to polygons that the engine will use. ---- .. _class_NavigationPolygon_method_add_outline_at_index: - void **add_outline_at_index** **(** :ref:`PoolVector2Array` outline, :ref:`int` index **)** Adds a :ref:`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 :ref:`make_polygons_from_outlines` in order for this array to be converted to polygons that the engine will use. ---- .. _class_NavigationPolygon_method_add_polygon: - void **add_polygon** **(** :ref:`PoolIntArray` polygon **)** Adds a polygon using the indices of the vertices you get when calling :ref:`get_vertices`. ---- .. _class_NavigationPolygon_method_clear_outlines: - void **clear_outlines** **(** **)** Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them. ---- .. _class_NavigationPolygon_method_clear_polygons: - void **clear_polygons** **(** **)** Clears the array of polygons, but it doesn't clear the array of outlines and vertices. ---- .. _class_NavigationPolygon_method_get_mesh: - :ref:`NavigationMesh` **get_mesh** **(** **)** Returns the :ref:`NavigationMesh` resulting from this navigation polygon. This navmesh can be used to update the navmesh of a region with the :ref:`NavigationServer.region_set_navmesh` API directly (as 2D uses the 3D server behind the scene). ---- .. _class_NavigationPolygon_method_get_outline: - :ref:`PoolVector2Array` **get_outline** **(** :ref:`int` idx **)** |const| Returns a :ref:`PoolVector2Array` containing the vertices of an outline that was created in the editor or by script. ---- .. _class_NavigationPolygon_method_get_outline_count: - :ref:`int` **get_outline_count** **(** **)** |const| Returns the number of outlines that were created in the editor or by script. ---- .. _class_NavigationPolygon_method_get_polygon: - :ref:`PoolIntArray` **get_polygon** **(** :ref:`int` idx **)** Returns a :ref:`PoolIntArray` containing the indices of the vertices of a created polygon. ---- .. _class_NavigationPolygon_method_get_polygon_count: - :ref:`int` **get_polygon_count** **(** **)** |const| Returns the count of all polygons. ---- .. _class_NavigationPolygon_method_get_vertices: - :ref:`PoolVector2Array` **get_vertices** **(** **)** |const| Returns a :ref:`PoolVector2Array` containing all the vertices being used to create the polygons. ---- .. _class_NavigationPolygon_method_make_polygons_from_outlines: - void **make_polygons_from_outlines** **(** **)** Creates polygons from the outlines added in the editor or by script. ---- .. _class_NavigationPolygon_method_remove_outline: - void **remove_outline** **(** :ref:`int` idx **)** Removes an outline created in the editor or by script. You have to call :ref:`make_polygons_from_outlines` for the polygons to update. ---- .. _class_NavigationPolygon_method_set_outline: - void **set_outline** **(** :ref:`int` idx, :ref:`PoolVector2Array` outline **)** Changes an outline created in the editor or by script. You have to call :ref:`make_polygons_from_outlines` for the polygons to update. ---- .. _class_NavigationPolygon_method_set_vertices: - void **set_vertices** **(** :ref:`PoolVector2Array` vertices **)** Sets the vertices that can be then indexed to create polygons with the :ref:`add_polygon` method. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`