2017-09-12 20:42:36 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2023-03-01 00:44:37 +00:00
<class name= "NavigationPolygon" inherits= "Resource" is_experimental= "true" version= "4.1" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2017-09-12 20:42:36 +00:00
<brief_description >
2023-04-28 20:59:03 +00:00
A navigation polygon that defines traversable areas and obstacles.
2017-09-12 20:42:36 +00:00
</brief_description>
<description >
2019-06-21 23:04:47 +00:00
There are two ways to create polygons. Either by using the [method add_outline] method, or using the [method add_polygon] method.
2018-10-21 17:38:57 +00:00
Using [method add_outline]:
2020-10-31 17:54:17 +00:00
[codeblocks]
[gdscript]
2018-10-21 17:38:57 +00:00
var polygon = NavigationPolygon.new()
2020-02-18 12:59:24 +00:00
var outline = PackedVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
2018-10-21 17:38:57 +00:00
polygon.add_outline(outline)
polygon.make_polygons_from_outlines()
2022-12-11 17:02:35 +00:00
$NavigationRegion2D.navigation_polygon = polygon
2020-10-31 17:54:17 +00:00
[/gdscript]
[csharp]
var polygon = new NavigationPolygon();
var outline = new Vector2[] { new Vector2(0, 0), new Vector2(0, 50), new Vector2(50, 50), new Vector2(50, 0) };
polygon.AddOutline(outline);
polygon.MakePolygonsFromOutlines();
2022-12-11 17:02:35 +00:00
GetNode< NavigationRegion2D> ("NavigationRegion2D").NavigationPolygon = polygon;
2020-10-31 17:54:17 +00:00
[/csharp]
[/codeblocks]
2018-10-21 17:38:57 +00:00
Using [method add_polygon] and indices of the vertices array.
2020-10-31 17:54:17 +00:00
[codeblocks]
[gdscript]
2018-10-21 17:38:57 +00:00
var polygon = NavigationPolygon.new()
2020-02-18 12:59:24 +00:00
var vertices = PackedVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
2020-10-31 17:54:17 +00:00
polygon.vertices = vertices
2021-11-11 06:59:17 +00:00
var indices = PackedInt32Array([0, 1, 2, 3])
2018-10-21 17:38:57 +00:00
polygon.add_polygon(indices)
2022-12-11 17:02:35 +00:00
$NavigationRegion2D.navigation_polygon = polygon
2020-10-31 17:54:17 +00:00
[/gdscript]
[csharp]
var polygon = new NavigationPolygon();
var vertices = new Vector2[] { new Vector2(0, 0), new Vector2(0, 50), new Vector2(50, 50), new Vector2(50, 0) };
polygon.Vertices = vertices;
2021-11-11 06:59:17 +00:00
var indices = new int[] { 0, 1, 2, 3 };
2020-10-31 17:54:17 +00:00
polygon.AddPolygon(indices);
2022-12-11 17:02:35 +00:00
GetNode< NavigationRegion2D> ("NavigationRegion2D").NavigationPolygon = polygon;
2020-10-31 17:54:17 +00:00
[/csharp]
[/codeblocks]
2017-09-12 20:42:36 +00:00
</description>
<tutorials >
2020-10-01 08:34:47 +00:00
<link title= "2D Navigation Demo" > https://godotengine.org/asset-library/asset/117</link>
2023-01-11 05:05:04 +00:00
<link title= "Using NavigationMeshes" > $DOCS_URL/tutorials/navigation/navigation_using_navigationmeshes.html</link>
2017-09-12 20:42:36 +00:00
</tutorials>
<methods >
<method name= "add_outline" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "outline" type= "PackedVector2Array" />
2017-09-12 20:42:36 +00:00
<description >
2020-02-18 12:59:24 +00:00
Appends a [PackedVector2Array] 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.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "add_outline_at_index" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "outline" type= "PackedVector2Array" />
<param index= "1" name= "index" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2020-02-18 12:59:24 +00:00
Adds a [PackedVector2Array] 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.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "add_polygon" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "polygon" type= "PackedInt32Array" />
2017-09-12 20:42:36 +00:00
<description >
2018-10-21 17:38:57 +00:00
Adds a polygon using the indices of the vertices you get when calling [method get_vertices].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "clear_outlines" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2017-09-12 20:42:36 +00:00
<description >
2018-10-21 17:38:57 +00:00
Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "clear_polygons" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2017-09-12 20:42:36 +00:00
<description >
2018-10-21 17:38:57 +00:00
Clears the array of polygons, but it doesn't clear the array of outlines and vertices.
2017-09-12 20:42:36 +00:00
</description>
</method>
2022-12-11 17:02:35 +00:00
<method name= "get_navigation_mesh" >
2022-06-02 07:25:42 +00:00
<return type= "NavigationMesh" />
<description >
2022-12-11 17:02:35 +00:00
Returns the [NavigationMesh] resulting from this navigation polygon. This navigation mesh can be used to update the navigation mesh of a region with the [method NavigationServer3D.region_set_navigation_mesh] API directly (as 2D uses the 3D server behind the scene).
2022-06-02 07:25:42 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "get_outline" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "PackedVector2Array" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "idx" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2020-02-18 12:59:24 +00:00
Returns a [PackedVector2Array] containing the vertices of an outline that was created in the editor or by script.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_outline_count" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2018-10-21 17:38:57 +00:00
Returns the number of outlines that were created in the editor or by script.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_polygon" >
2021-07-30 13:28:05 +00:00
<return type= "PackedInt32Array" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "idx" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2020-02-25 17:10:58 +00:00
Returns a [PackedInt32Array] containing the indices of the vertices of a created polygon.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "get_polygon_count" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2018-10-21 17:38:57 +00:00
Returns the count of all polygons.
2017-09-12 20:42:36 +00:00
</description>
</method>
2017-12-07 07:29:38 +00:00
<method name= "get_vertices" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "PackedVector2Array" />
2017-12-07 07:29:38 +00:00
<description >
2020-02-18 12:59:24 +00:00
Returns a [PackedVector2Array] containing all the vertices being used to create the polygons.
2017-12-07 07:29:38 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "make_polygons_from_outlines" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2017-09-12 20:42:36 +00:00
<description >
2018-10-21 17:38:57 +00:00
Creates polygons from the outlines added in the editor or by script.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "remove_outline" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "idx" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2018-10-21 17:38:57 +00:00
Removes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "set_outline" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "idx" type= "int" />
<param index= "1" name= "outline" type= "PackedVector2Array" />
2017-09-12 20:42:36 +00:00
<description >
2018-10-21 17:38:57 +00:00
Changes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update.
2017-09-12 20:42:36 +00:00
</description>
</method>
2017-12-07 07:29:38 +00:00
<method name= "set_vertices" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "vertices" type= "PackedVector2Array" />
2017-12-07 07:29:38 +00:00
<description >
2018-10-21 17:38:57 +00:00
Sets the vertices that can be then indexed to create polygons with the [method add_polygon] method.
2017-12-07 07:29:38 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
</methods>
2023-06-13 08:35:52 +00:00
<members >
<member name= "cell_size" type= "float" setter= "set_cell_size" getter= "get_cell_size" default= "1.0" >
The cell size used to rasterize the navigation mesh vertices. Must match with the cell size on the navigation map.
</member>
</members>
2017-09-12 20:42:36 +00:00
</class>