class_navigationpolygon.rst 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.3/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.3/doc/classes/NavigationPolygon.xml.
  6. .. _class_NavigationPolygon:
  7. NavigationPolygon
  8. =================
  9. **Experimental:** This class may be changed or removed in future versions.
  10. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  11. A 2D navigation mesh that describes a traversable surface for pathfinding.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. A navigation mesh can be created either by baking it with the help of the :ref:`NavigationServer2D<class_NavigationServer2D>`, or by adding vertices and convex polygon indices arrays manually.
  16. To bake a navigation mesh at least one outline needs to be added that defines the outer bounds of the baked area.
  17. .. tabs::
  18. .. code-tab:: gdscript
  19. var new_navigation_mesh = NavigationPolygon.new()
  20. var bounding_outline = PackedVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
  21. new_navigation_mesh.add_outline(bounding_outline)
  22. NavigationServer2D.bake_from_source_geometry_data(new_navigation_mesh, NavigationMeshSourceGeometryData2D.new());
  23. $NavigationRegion2D.navigation_polygon = new_navigation_mesh
  24. .. code-tab:: csharp
  25. var newNavigationMesh = new NavigationPolygon();
  26. var boundingOutline = new Vector2[] { new Vector2(0, 0), new Vector2(0, 50), new Vector2(50, 50), new Vector2(50, 0) };
  27. newNavigationMesh.AddOutline(boundingOutline);
  28. NavigationServer2D.BakeFromSourceGeometryData(newNavigationMesh, new NavigationMeshSourceGeometryData2D());
  29. GetNode<NavigationRegion2D>("NavigationRegion2D").NavigationPolygon = newNavigationMesh;
  30. Adding vertices and polygon indices manually.
  31. .. tabs::
  32. .. code-tab:: gdscript
  33. var new_navigation_mesh = NavigationPolygon.new()
  34. var new_vertices = PackedVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
  35. new_navigation_mesh.vertices = new_vertices
  36. var new_polygon_indices = PackedInt32Array([0, 1, 2, 3])
  37. new_navigation_mesh.add_polygon(new_polygon_indices)
  38. $NavigationRegion2D.navigation_polygon = new_navigation_mesh
  39. .. code-tab:: csharp
  40. var newNavigationMesh = new NavigationPolygon();
  41. var newVertices = new Vector2[] { new Vector2(0, 0), new Vector2(0, 50), new Vector2(50, 50), new Vector2(50, 0) };
  42. newNavigationMesh.Vertices = newVertices;
  43. var newPolygonIndices = new int[] { 0, 1, 2, 3 };
  44. newNavigationMesh.AddPolygon(newPolygonIndices);
  45. GetNode<NavigationRegion2D>("NavigationRegion2D").NavigationPolygon = newNavigationMesh;
  46. .. rst-class:: classref-introduction-group
  47. Tutorials
  48. ---------
  49. - :doc:`Using NavigationMeshes <../tutorials/navigation/navigation_using_navigationmeshes>`
  50. - `Navigation Polygon 2D Demo <https://godotengine.org/asset-library/asset/2722>`__
  51. .. rst-class:: classref-reftable-group
  52. Properties
  53. ----------
  54. .. table::
  55. :widths: auto
  56. +----------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------+
  57. | :ref:`float<class_float>` | :ref:`agent_radius<class_NavigationPolygon_property_agent_radius>` | ``10.0`` |
  58. +----------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------+
  59. | :ref:`Rect2<class_Rect2>` | :ref:`baking_rect<class_NavigationPolygon_property_baking_rect>` | ``Rect2(0, 0, 0, 0)`` |
  60. +----------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------+
  61. | :ref:`Vector2<class_Vector2>` | :ref:`baking_rect_offset<class_NavigationPolygon_property_baking_rect_offset>` | ``Vector2(0, 0)`` |
  62. +----------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------+
  63. | :ref:`float<class_float>` | :ref:`border_size<class_NavigationPolygon_property_border_size>` | ``0.0`` |
  64. +----------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------+
  65. | :ref:`float<class_float>` | :ref:`cell_size<class_NavigationPolygon_property_cell_size>` | ``1.0`` |
  66. +----------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------+
  67. | :ref:`int<class_int>` | :ref:`parsed_collision_mask<class_NavigationPolygon_property_parsed_collision_mask>` | ``4294967295`` |
  68. +----------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------+
  69. | :ref:`ParsedGeometryType<enum_NavigationPolygon_ParsedGeometryType>` | :ref:`parsed_geometry_type<class_NavigationPolygon_property_parsed_geometry_type>` | ``2`` |
  70. +----------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------+
  71. | :ref:`StringName<class_StringName>` | :ref:`source_geometry_group_name<class_NavigationPolygon_property_source_geometry_group_name>` | ``&"navigation_polygon_source_geometry_group"`` |
  72. +----------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------+
  73. | :ref:`SourceGeometryMode<enum_NavigationPolygon_SourceGeometryMode>` | :ref:`source_geometry_mode<class_NavigationPolygon_property_source_geometry_mode>` | ``0`` |
  74. +----------------------------------------------------------------------+------------------------------------------------------------------------------------------------+-------------------------------------------------+
  75. .. rst-class:: classref-reftable-group
  76. Methods
  77. -------
  78. .. table::
  79. :widths: auto
  80. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | |void| | :ref:`add_outline<class_NavigationPolygon_method_add_outline>`\ (\ outline\: :ref:`PackedVector2Array<class_PackedVector2Array>`\ ) |
  82. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | |void| | :ref:`add_outline_at_index<class_NavigationPolygon_method_add_outline_at_index>`\ (\ outline\: :ref:`PackedVector2Array<class_PackedVector2Array>`, index\: :ref:`int<class_int>`\ ) |
  84. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | |void| | :ref:`add_polygon<class_NavigationPolygon_method_add_polygon>`\ (\ polygon\: :ref:`PackedInt32Array<class_PackedInt32Array>`\ ) |
  86. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | |void| | :ref:`clear<class_NavigationPolygon_method_clear>`\ (\ ) |
  88. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | |void| | :ref:`clear_outlines<class_NavigationPolygon_method_clear_outlines>`\ (\ ) |
  90. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | |void| | :ref:`clear_polygons<class_NavigationPolygon_method_clear_polygons>`\ (\ ) |
  92. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | :ref:`NavigationMesh<class_NavigationMesh>` | :ref:`get_navigation_mesh<class_NavigationPolygon_method_get_navigation_mesh>`\ (\ ) |
  94. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | :ref:`PackedVector2Array<class_PackedVector2Array>` | :ref:`get_outline<class_NavigationPolygon_method_get_outline>`\ (\ idx\: :ref:`int<class_int>`\ ) |const| |
  96. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :ref:`int<class_int>` | :ref:`get_outline_count<class_NavigationPolygon_method_get_outline_count>`\ (\ ) |const| |
  98. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | :ref:`bool<class_bool>` | :ref:`get_parsed_collision_mask_value<class_NavigationPolygon_method_get_parsed_collision_mask_value>`\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| |
  100. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`PackedInt32Array<class_PackedInt32Array>` | :ref:`get_polygon<class_NavigationPolygon_method_get_polygon>`\ (\ idx\: :ref:`int<class_int>`\ ) |
  102. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | :ref:`int<class_int>` | :ref:`get_polygon_count<class_NavigationPolygon_method_get_polygon_count>`\ (\ ) |const| |
  104. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | :ref:`PackedVector2Array<class_PackedVector2Array>` | :ref:`get_vertices<class_NavigationPolygon_method_get_vertices>`\ (\ ) |const| |
  106. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | |void| | :ref:`make_polygons_from_outlines<class_NavigationPolygon_method_make_polygons_from_outlines>`\ (\ ) |
  108. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | |void| | :ref:`remove_outline<class_NavigationPolygon_method_remove_outline>`\ (\ idx\: :ref:`int<class_int>`\ ) |
  110. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | |void| | :ref:`set_outline<class_NavigationPolygon_method_set_outline>`\ (\ idx\: :ref:`int<class_int>`, outline\: :ref:`PackedVector2Array<class_PackedVector2Array>`\ ) |
  112. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | |void| | :ref:`set_parsed_collision_mask_value<class_NavigationPolygon_method_set_parsed_collision_mask_value>`\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) |
  114. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | |void| | :ref:`set_vertices<class_NavigationPolygon_method_set_vertices>`\ (\ vertices\: :ref:`PackedVector2Array<class_PackedVector2Array>`\ ) |
  116. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. .. rst-class:: classref-section-separator
  118. ----
  119. .. rst-class:: classref-descriptions-group
  120. Enumerations
  121. ------------
  122. .. _enum_NavigationPolygon_ParsedGeometryType:
  123. .. rst-class:: classref-enumeration
  124. enum **ParsedGeometryType**: :ref:`🔗<enum_NavigationPolygon_ParsedGeometryType>`
  125. .. _class_NavigationPolygon_constant_PARSED_GEOMETRY_MESH_INSTANCES:
  126. .. rst-class:: classref-enumeration-constant
  127. :ref:`ParsedGeometryType<enum_NavigationPolygon_ParsedGeometryType>` **PARSED_GEOMETRY_MESH_INSTANCES** = ``0``
  128. Parses mesh instances as obstruction geometry. This includes :ref:`Polygon2D<class_Polygon2D>`, :ref:`MeshInstance2D<class_MeshInstance2D>`, :ref:`MultiMeshInstance2D<class_MultiMeshInstance2D>`, and :ref:`TileMap<class_TileMap>` nodes.
  129. Meshes are only parsed when they use a 2D vertices surface format.
  130. .. _class_NavigationPolygon_constant_PARSED_GEOMETRY_STATIC_COLLIDERS:
  131. .. rst-class:: classref-enumeration-constant
  132. :ref:`ParsedGeometryType<enum_NavigationPolygon_ParsedGeometryType>` **PARSED_GEOMETRY_STATIC_COLLIDERS** = ``1``
  133. Parses :ref:`StaticBody2D<class_StaticBody2D>` and :ref:`TileMap<class_TileMap>` colliders as obstruction geometry. The collider should be in any of the layers specified by :ref:`parsed_collision_mask<class_NavigationPolygon_property_parsed_collision_mask>`.
  134. .. _class_NavigationPolygon_constant_PARSED_GEOMETRY_BOTH:
  135. .. rst-class:: classref-enumeration-constant
  136. :ref:`ParsedGeometryType<enum_NavigationPolygon_ParsedGeometryType>` **PARSED_GEOMETRY_BOTH** = ``2``
  137. Both :ref:`PARSED_GEOMETRY_MESH_INSTANCES<class_NavigationPolygon_constant_PARSED_GEOMETRY_MESH_INSTANCES>` and :ref:`PARSED_GEOMETRY_STATIC_COLLIDERS<class_NavigationPolygon_constant_PARSED_GEOMETRY_STATIC_COLLIDERS>`.
  138. .. _class_NavigationPolygon_constant_PARSED_GEOMETRY_MAX:
  139. .. rst-class:: classref-enumeration-constant
  140. :ref:`ParsedGeometryType<enum_NavigationPolygon_ParsedGeometryType>` **PARSED_GEOMETRY_MAX** = ``3``
  141. Represents the size of the :ref:`ParsedGeometryType<enum_NavigationPolygon_ParsedGeometryType>` enum.
  142. .. rst-class:: classref-item-separator
  143. ----
  144. .. _enum_NavigationPolygon_SourceGeometryMode:
  145. .. rst-class:: classref-enumeration
  146. enum **SourceGeometryMode**: :ref:`🔗<enum_NavigationPolygon_SourceGeometryMode>`
  147. .. _class_NavigationPolygon_constant_SOURCE_GEOMETRY_ROOT_NODE_CHILDREN:
  148. .. rst-class:: classref-enumeration-constant
  149. :ref:`SourceGeometryMode<enum_NavigationPolygon_SourceGeometryMode>` **SOURCE_GEOMETRY_ROOT_NODE_CHILDREN** = ``0``
  150. Scans the child nodes of the root node recursively for geometry.
  151. .. _class_NavigationPolygon_constant_SOURCE_GEOMETRY_GROUPS_WITH_CHILDREN:
  152. .. rst-class:: classref-enumeration-constant
  153. :ref:`SourceGeometryMode<enum_NavigationPolygon_SourceGeometryMode>` **SOURCE_GEOMETRY_GROUPS_WITH_CHILDREN** = ``1``
  154. Scans nodes in a group and their child nodes recursively for geometry. The group is specified by :ref:`source_geometry_group_name<class_NavigationPolygon_property_source_geometry_group_name>`.
  155. .. _class_NavigationPolygon_constant_SOURCE_GEOMETRY_GROUPS_EXPLICIT:
  156. .. rst-class:: classref-enumeration-constant
  157. :ref:`SourceGeometryMode<enum_NavigationPolygon_SourceGeometryMode>` **SOURCE_GEOMETRY_GROUPS_EXPLICIT** = ``2``
  158. Uses nodes in a group for geometry. The group is specified by :ref:`source_geometry_group_name<class_NavigationPolygon_property_source_geometry_group_name>`.
  159. .. _class_NavigationPolygon_constant_SOURCE_GEOMETRY_MAX:
  160. .. rst-class:: classref-enumeration-constant
  161. :ref:`SourceGeometryMode<enum_NavigationPolygon_SourceGeometryMode>` **SOURCE_GEOMETRY_MAX** = ``3``
  162. Represents the size of the :ref:`SourceGeometryMode<enum_NavigationPolygon_SourceGeometryMode>` enum.
  163. .. rst-class:: classref-section-separator
  164. ----
  165. .. rst-class:: classref-descriptions-group
  166. Property Descriptions
  167. ---------------------
  168. .. _class_NavigationPolygon_property_agent_radius:
  169. .. rst-class:: classref-property
  170. :ref:`float<class_float>` **agent_radius** = ``10.0`` :ref:`🔗<class_NavigationPolygon_property_agent_radius>`
  171. .. rst-class:: classref-property-setget
  172. - |void| **set_agent_radius**\ (\ value\: :ref:`float<class_float>`\ )
  173. - :ref:`float<class_float>` **get_agent_radius**\ (\ )
  174. The distance to erode/shrink the walkable surface when baking the navigation mesh.
  175. .. rst-class:: classref-item-separator
  176. ----
  177. .. _class_NavigationPolygon_property_baking_rect:
  178. .. rst-class:: classref-property
  179. :ref:`Rect2<class_Rect2>` **baking_rect** = ``Rect2(0, 0, 0, 0)`` :ref:`🔗<class_NavigationPolygon_property_baking_rect>`
  180. .. rst-class:: classref-property-setget
  181. - |void| **set_baking_rect**\ (\ value\: :ref:`Rect2<class_Rect2>`\ )
  182. - :ref:`Rect2<class_Rect2>` **get_baking_rect**\ (\ )
  183. If the baking :ref:`Rect2<class_Rect2>` has an area the navigation mesh baking will be restricted to its enclosing area.
  184. .. rst-class:: classref-item-separator
  185. ----
  186. .. _class_NavigationPolygon_property_baking_rect_offset:
  187. .. rst-class:: classref-property
  188. :ref:`Vector2<class_Vector2>` **baking_rect_offset** = ``Vector2(0, 0)`` :ref:`🔗<class_NavigationPolygon_property_baking_rect_offset>`
  189. .. rst-class:: classref-property-setget
  190. - |void| **set_baking_rect_offset**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
  191. - :ref:`Vector2<class_Vector2>` **get_baking_rect_offset**\ (\ )
  192. The position offset applied to the :ref:`baking_rect<class_NavigationPolygon_property_baking_rect>` :ref:`Rect2<class_Rect2>`.
  193. .. rst-class:: classref-item-separator
  194. ----
  195. .. _class_NavigationPolygon_property_border_size:
  196. .. rst-class:: classref-property
  197. :ref:`float<class_float>` **border_size** = ``0.0`` :ref:`🔗<class_NavigationPolygon_property_border_size>`
  198. .. rst-class:: classref-property-setget
  199. - |void| **set_border_size**\ (\ value\: :ref:`float<class_float>`\ )
  200. - :ref:`float<class_float>` **get_border_size**\ (\ )
  201. The size of the non-navigable border around the bake bounding area defined by the :ref:`baking_rect<class_NavigationPolygon_property_baking_rect>` :ref:`Rect2<class_Rect2>`.
  202. In conjunction with the :ref:`baking_rect<class_NavigationPolygon_property_baking_rect>` the border size can be used to bake tile aligned navigation meshes without the tile edges being shrunk by :ref:`agent_radius<class_NavigationPolygon_property_agent_radius>`.
  203. .. rst-class:: classref-item-separator
  204. ----
  205. .. _class_NavigationPolygon_property_cell_size:
  206. .. rst-class:: classref-property
  207. :ref:`float<class_float>` **cell_size** = ``1.0`` :ref:`🔗<class_NavigationPolygon_property_cell_size>`
  208. .. rst-class:: classref-property-setget
  209. - |void| **set_cell_size**\ (\ value\: :ref:`float<class_float>`\ )
  210. - :ref:`float<class_float>` **get_cell_size**\ (\ )
  211. The cell size used to rasterize the navigation mesh vertices. Must match with the cell size on the navigation map.
  212. .. rst-class:: classref-item-separator
  213. ----
  214. .. _class_NavigationPolygon_property_parsed_collision_mask:
  215. .. rst-class:: classref-property
  216. :ref:`int<class_int>` **parsed_collision_mask** = ``4294967295`` :ref:`🔗<class_NavigationPolygon_property_parsed_collision_mask>`
  217. .. rst-class:: classref-property-setget
  218. - |void| **set_parsed_collision_mask**\ (\ value\: :ref:`int<class_int>`\ )
  219. - :ref:`int<class_int>` **get_parsed_collision_mask**\ (\ )
  220. The physics layers to scan for static colliders.
  221. Only used when :ref:`parsed_geometry_type<class_NavigationPolygon_property_parsed_geometry_type>` is :ref:`PARSED_GEOMETRY_STATIC_COLLIDERS<class_NavigationPolygon_constant_PARSED_GEOMETRY_STATIC_COLLIDERS>` or :ref:`PARSED_GEOMETRY_BOTH<class_NavigationPolygon_constant_PARSED_GEOMETRY_BOTH>`.
  222. .. rst-class:: classref-item-separator
  223. ----
  224. .. _class_NavigationPolygon_property_parsed_geometry_type:
  225. .. rst-class:: classref-property
  226. :ref:`ParsedGeometryType<enum_NavigationPolygon_ParsedGeometryType>` **parsed_geometry_type** = ``2`` :ref:`🔗<class_NavigationPolygon_property_parsed_geometry_type>`
  227. .. rst-class:: classref-property-setget
  228. - |void| **set_parsed_geometry_type**\ (\ value\: :ref:`ParsedGeometryType<enum_NavigationPolygon_ParsedGeometryType>`\ )
  229. - :ref:`ParsedGeometryType<enum_NavigationPolygon_ParsedGeometryType>` **get_parsed_geometry_type**\ (\ )
  230. Determines which type of nodes will be parsed as geometry. See :ref:`ParsedGeometryType<enum_NavigationPolygon_ParsedGeometryType>` for possible values.
  231. .. rst-class:: classref-item-separator
  232. ----
  233. .. _class_NavigationPolygon_property_source_geometry_group_name:
  234. .. rst-class:: classref-property
  235. :ref:`StringName<class_StringName>` **source_geometry_group_name** = ``&"navigation_polygon_source_geometry_group"`` :ref:`🔗<class_NavigationPolygon_property_source_geometry_group_name>`
  236. .. rst-class:: classref-property-setget
  237. - |void| **set_source_geometry_group_name**\ (\ value\: :ref:`StringName<class_StringName>`\ )
  238. - :ref:`StringName<class_StringName>` **get_source_geometry_group_name**\ (\ )
  239. The group name of nodes that should be parsed for baking source geometry.
  240. Only used when :ref:`source_geometry_mode<class_NavigationPolygon_property_source_geometry_mode>` is :ref:`SOURCE_GEOMETRY_GROUPS_WITH_CHILDREN<class_NavigationPolygon_constant_SOURCE_GEOMETRY_GROUPS_WITH_CHILDREN>` or :ref:`SOURCE_GEOMETRY_GROUPS_EXPLICIT<class_NavigationPolygon_constant_SOURCE_GEOMETRY_GROUPS_EXPLICIT>`.
  241. .. rst-class:: classref-item-separator
  242. ----
  243. .. _class_NavigationPolygon_property_source_geometry_mode:
  244. .. rst-class:: classref-property
  245. :ref:`SourceGeometryMode<enum_NavigationPolygon_SourceGeometryMode>` **source_geometry_mode** = ``0`` :ref:`🔗<class_NavigationPolygon_property_source_geometry_mode>`
  246. .. rst-class:: classref-property-setget
  247. - |void| **set_source_geometry_mode**\ (\ value\: :ref:`SourceGeometryMode<enum_NavigationPolygon_SourceGeometryMode>`\ )
  248. - :ref:`SourceGeometryMode<enum_NavigationPolygon_SourceGeometryMode>` **get_source_geometry_mode**\ (\ )
  249. The source of the geometry used when baking. See :ref:`SourceGeometryMode<enum_NavigationPolygon_SourceGeometryMode>` for possible values.
  250. .. rst-class:: classref-section-separator
  251. ----
  252. .. rst-class:: classref-descriptions-group
  253. Method Descriptions
  254. -------------------
  255. .. _class_NavigationPolygon_method_add_outline:
  256. .. rst-class:: classref-method
  257. |void| **add_outline**\ (\ outline\: :ref:`PackedVector2Array<class_PackedVector2Array>`\ ) :ref:`🔗<class_NavigationPolygon_method_add_outline>`
  258. Appends a :ref:`PackedVector2Array<class_PackedVector2Array>` that contains the vertices of an outline to the internal array that contains all the outlines.
  259. .. rst-class:: classref-item-separator
  260. ----
  261. .. _class_NavigationPolygon_method_add_outline_at_index:
  262. .. rst-class:: classref-method
  263. |void| **add_outline_at_index**\ (\ outline\: :ref:`PackedVector2Array<class_PackedVector2Array>`, index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_NavigationPolygon_method_add_outline_at_index>`
  264. Adds a :ref:`PackedVector2Array<class_PackedVector2Array>` that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position.
  265. .. rst-class:: classref-item-separator
  266. ----
  267. .. _class_NavigationPolygon_method_add_polygon:
  268. .. rst-class:: classref-method
  269. |void| **add_polygon**\ (\ polygon\: :ref:`PackedInt32Array<class_PackedInt32Array>`\ ) :ref:`🔗<class_NavigationPolygon_method_add_polygon>`
  270. Adds a polygon using the indices of the vertices you get when calling :ref:`get_vertices<class_NavigationPolygon_method_get_vertices>`.
  271. .. rst-class:: classref-item-separator
  272. ----
  273. .. _class_NavigationPolygon_method_clear:
  274. .. rst-class:: classref-method
  275. |void| **clear**\ (\ ) :ref:`🔗<class_NavigationPolygon_method_clear>`
  276. Clears the internal arrays for vertices and polygon indices.
  277. .. rst-class:: classref-item-separator
  278. ----
  279. .. _class_NavigationPolygon_method_clear_outlines:
  280. .. rst-class:: classref-method
  281. |void| **clear_outlines**\ (\ ) :ref:`🔗<class_NavigationPolygon_method_clear_outlines>`
  282. Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them.
  283. .. rst-class:: classref-item-separator
  284. ----
  285. .. _class_NavigationPolygon_method_clear_polygons:
  286. .. rst-class:: classref-method
  287. |void| **clear_polygons**\ (\ ) :ref:`🔗<class_NavigationPolygon_method_clear_polygons>`
  288. Clears the array of polygons, but it doesn't clear the array of outlines and vertices.
  289. .. rst-class:: classref-item-separator
  290. ----
  291. .. _class_NavigationPolygon_method_get_navigation_mesh:
  292. .. rst-class:: classref-method
  293. :ref:`NavigationMesh<class_NavigationMesh>` **get_navigation_mesh**\ (\ ) :ref:`🔗<class_NavigationPolygon_method_get_navigation_mesh>`
  294. Returns the :ref:`NavigationMesh<class_NavigationMesh>` resulting from this navigation polygon. This navigation mesh can be used to update the navigation mesh of a region with the :ref:`NavigationServer3D.region_set_navigation_mesh<class_NavigationServer3D_method_region_set_navigation_mesh>` API directly (as 2D uses the 3D server behind the scene).
  295. .. rst-class:: classref-item-separator
  296. ----
  297. .. _class_NavigationPolygon_method_get_outline:
  298. .. rst-class:: classref-method
  299. :ref:`PackedVector2Array<class_PackedVector2Array>` **get_outline**\ (\ idx\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_NavigationPolygon_method_get_outline>`
  300. Returns a :ref:`PackedVector2Array<class_PackedVector2Array>` containing the vertices of an outline that was created in the editor or by script.
  301. .. rst-class:: classref-item-separator
  302. ----
  303. .. _class_NavigationPolygon_method_get_outline_count:
  304. .. rst-class:: classref-method
  305. :ref:`int<class_int>` **get_outline_count**\ (\ ) |const| :ref:`🔗<class_NavigationPolygon_method_get_outline_count>`
  306. Returns the number of outlines that were created in the editor or by script.
  307. .. rst-class:: classref-item-separator
  308. ----
  309. .. _class_NavigationPolygon_method_get_parsed_collision_mask_value:
  310. .. rst-class:: classref-method
  311. :ref:`bool<class_bool>` **get_parsed_collision_mask_value**\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_NavigationPolygon_method_get_parsed_collision_mask_value>`
  312. Returns whether or not the specified layer of the :ref:`parsed_collision_mask<class_NavigationPolygon_property_parsed_collision_mask>` is enabled, given a ``layer_number`` between 1 and 32.
  313. .. rst-class:: classref-item-separator
  314. ----
  315. .. _class_NavigationPolygon_method_get_polygon:
  316. .. rst-class:: classref-method
  317. :ref:`PackedInt32Array<class_PackedInt32Array>` **get_polygon**\ (\ idx\: :ref:`int<class_int>`\ ) :ref:`🔗<class_NavigationPolygon_method_get_polygon>`
  318. Returns a :ref:`PackedInt32Array<class_PackedInt32Array>` containing the indices of the vertices of a created polygon.
  319. .. rst-class:: classref-item-separator
  320. ----
  321. .. _class_NavigationPolygon_method_get_polygon_count:
  322. .. rst-class:: classref-method
  323. :ref:`int<class_int>` **get_polygon_count**\ (\ ) |const| :ref:`🔗<class_NavigationPolygon_method_get_polygon_count>`
  324. Returns the count of all polygons.
  325. .. rst-class:: classref-item-separator
  326. ----
  327. .. _class_NavigationPolygon_method_get_vertices:
  328. .. rst-class:: classref-method
  329. :ref:`PackedVector2Array<class_PackedVector2Array>` **get_vertices**\ (\ ) |const| :ref:`🔗<class_NavigationPolygon_method_get_vertices>`
  330. Returns a :ref:`PackedVector2Array<class_PackedVector2Array>` containing all the vertices being used to create the polygons.
  331. .. rst-class:: classref-item-separator
  332. ----
  333. .. _class_NavigationPolygon_method_make_polygons_from_outlines:
  334. .. rst-class:: classref-method
  335. |void| **make_polygons_from_outlines**\ (\ ) :ref:`🔗<class_NavigationPolygon_method_make_polygons_from_outlines>`
  336. **Deprecated:** Use :ref:`NavigationServer2D.parse_source_geometry_data<class_NavigationServer2D_method_parse_source_geometry_data>` and :ref:`NavigationServer2D.bake_from_source_geometry_data<class_NavigationServer2D_method_bake_from_source_geometry_data>` instead.
  337. Creates polygons from the outlines added in the editor or by script.
  338. .. rst-class:: classref-item-separator
  339. ----
  340. .. _class_NavigationPolygon_method_remove_outline:
  341. .. rst-class:: classref-method
  342. |void| **remove_outline**\ (\ idx\: :ref:`int<class_int>`\ ) :ref:`🔗<class_NavigationPolygon_method_remove_outline>`
  343. Removes an outline created in the editor or by script. You have to call :ref:`make_polygons_from_outlines<class_NavigationPolygon_method_make_polygons_from_outlines>` for the polygons to update.
  344. .. rst-class:: classref-item-separator
  345. ----
  346. .. _class_NavigationPolygon_method_set_outline:
  347. .. rst-class:: classref-method
  348. |void| **set_outline**\ (\ idx\: :ref:`int<class_int>`, outline\: :ref:`PackedVector2Array<class_PackedVector2Array>`\ ) :ref:`🔗<class_NavigationPolygon_method_set_outline>`
  349. Changes an outline created in the editor or by script. You have to call :ref:`make_polygons_from_outlines<class_NavigationPolygon_method_make_polygons_from_outlines>` for the polygons to update.
  350. .. rst-class:: classref-item-separator
  351. ----
  352. .. _class_NavigationPolygon_method_set_parsed_collision_mask_value:
  353. .. rst-class:: classref-method
  354. |void| **set_parsed_collision_mask_value**\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_NavigationPolygon_method_set_parsed_collision_mask_value>`
  355. Based on ``value``, enables or disables the specified layer in the :ref:`parsed_collision_mask<class_NavigationPolygon_property_parsed_collision_mask>`, given a ``layer_number`` between 1 and 32.
  356. .. rst-class:: classref-item-separator
  357. ----
  358. .. _class_NavigationPolygon_method_set_vertices:
  359. .. rst-class:: classref-method
  360. |void| **set_vertices**\ (\ vertices\: :ref:`PackedVector2Array<class_PackedVector2Array>`\ ) :ref:`🔗<class_NavigationPolygon_method_set_vertices>`
  361. Sets the vertices that can be then indexed to create polygons with the :ref:`add_polygon<class_NavigationPolygon_method_add_polygon>` method.
  362. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  363. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  364. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  365. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  366. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  367. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  368. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  369. .. |void| replace:: :abbr:`void (No return value.)`