class_navigationpolygon.rst 33 KB

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