class_navigationpolygon.rst 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/NavigationPolygon.xml.
  6. .. _class_NavigationPolygon:
  7. NavigationPolygon
  8. =================
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  10. A node that has methods to draw outlines or use indices of vertices to create navigation polygons.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. There are two ways to create polygons. Either by using the :ref:`add_outline<class_NavigationPolygon_method_add_outline>` method, or using the :ref:`add_polygon<class_NavigationPolygon_method_add_polygon>` method.
  15. Using :ref:`add_outline<class_NavigationPolygon_method_add_outline>`:
  16. ::
  17. var polygon = NavigationPolygon.new()
  18. var outline = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
  19. polygon.add_outline(outline)
  20. polygon.make_polygons_from_outlines()
  21. $NavigationPolygonInstance.navpoly = polygon
  22. Using :ref:`add_polygon<class_NavigationPolygon_method_add_polygon>` and indices of the vertices array.
  23. ::
  24. var polygon = NavigationPolygon.new()
  25. var vertices = PoolVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
  26. polygon.set_vertices(vertices)
  27. var indices = PoolIntArray([0, 1, 2, 3])
  28. polygon.add_polygon(indices)
  29. $NavigationPolygonInstance.navpoly = polygon
  30. .. rst-class:: classref-introduction-group
  31. Tutorials
  32. ---------
  33. - `2D Navigation Demo <https://godotengine.org/asset-library/asset/117>`__
  34. .. rst-class:: classref-reftable-group
  35. Methods
  36. -------
  37. .. table::
  38. :widths: auto
  39. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`add_outline<class_NavigationPolygon_method_add_outline>` **(** :ref:`PoolVector2Array<class_PoolVector2Array>` outline **)** |
  41. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`add_outline_at_index<class_NavigationPolygon_method_add_outline_at_index>` **(** :ref:`PoolVector2Array<class_PoolVector2Array>` outline, :ref:`int<class_int>` index **)** |
  43. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`add_polygon<class_NavigationPolygon_method_add_polygon>` **(** :ref:`PoolIntArray<class_PoolIntArray>` polygon **)** |
  45. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`clear_outlines<class_NavigationPolygon_method_clear_outlines>` **(** **)** |
  47. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`clear_polygons<class_NavigationPolygon_method_clear_polygons>` **(** **)** |
  49. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`NavigationMesh<class_NavigationMesh>` | :ref:`get_mesh<class_NavigationPolygon_method_get_mesh>` **(** **)** |
  51. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`PoolVector2Array<class_PoolVector2Array>` | :ref:`get_outline<class_NavigationPolygon_method_get_outline>` **(** :ref:`int<class_int>` idx **)** |const| |
  53. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`int<class_int>` | :ref:`get_outline_count<class_NavigationPolygon_method_get_outline_count>` **(** **)** |const| |
  55. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`PoolIntArray<class_PoolIntArray>` | :ref:`get_polygon<class_NavigationPolygon_method_get_polygon>` **(** :ref:`int<class_int>` idx **)** |
  57. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`int<class_int>` | :ref:`get_polygon_count<class_NavigationPolygon_method_get_polygon_count>` **(** **)** |const| |
  59. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`PoolVector2Array<class_PoolVector2Array>` | :ref:`get_vertices<class_NavigationPolygon_method_get_vertices>` **(** **)** |const| |
  61. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`make_polygons_from_outlines<class_NavigationPolygon_method_make_polygons_from_outlines>` **(** **)** |
  63. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | void | :ref:`remove_outline<class_NavigationPolygon_method_remove_outline>` **(** :ref:`int<class_int>` idx **)** |
  65. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | void | :ref:`set_outline<class_NavigationPolygon_method_set_outline>` **(** :ref:`int<class_int>` idx, :ref:`PoolVector2Array<class_PoolVector2Array>` outline **)** |
  67. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`set_vertices<class_NavigationPolygon_method_set_vertices>` **(** :ref:`PoolVector2Array<class_PoolVector2Array>` vertices **)** |
  69. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. .. rst-class:: classref-section-separator
  71. ----
  72. .. rst-class:: classref-descriptions-group
  73. Method Descriptions
  74. -------------------
  75. .. _class_NavigationPolygon_method_add_outline:
  76. .. rst-class:: classref-method
  77. void **add_outline** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` outline **)**
  78. Appends a :ref:`PoolVector2Array<class_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<class_NavigationPolygon_method_make_polygons_from_outlines>` in order for this array to be converted to polygons that the engine will use.
  79. .. rst-class:: classref-item-separator
  80. ----
  81. .. _class_NavigationPolygon_method_add_outline_at_index:
  82. .. rst-class:: classref-method
  83. void **add_outline_at_index** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` outline, :ref:`int<class_int>` index **)**
  84. Adds a :ref:`PoolVector2Array<class_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<class_NavigationPolygon_method_make_polygons_from_outlines>` in order for this array to be converted to polygons that the engine will use.
  85. .. rst-class:: classref-item-separator
  86. ----
  87. .. _class_NavigationPolygon_method_add_polygon:
  88. .. rst-class:: classref-method
  89. void **add_polygon** **(** :ref:`PoolIntArray<class_PoolIntArray>` polygon **)**
  90. Adds a polygon using the indices of the vertices you get when calling :ref:`get_vertices<class_NavigationPolygon_method_get_vertices>`.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_NavigationPolygon_method_clear_outlines:
  94. .. rst-class:: classref-method
  95. void **clear_outlines** **(** **)**
  96. Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them.
  97. .. rst-class:: classref-item-separator
  98. ----
  99. .. _class_NavigationPolygon_method_clear_polygons:
  100. .. rst-class:: classref-method
  101. void **clear_polygons** **(** **)**
  102. Clears the array of polygons, but it doesn't clear the array of outlines and vertices.
  103. .. rst-class:: classref-item-separator
  104. ----
  105. .. _class_NavigationPolygon_method_get_mesh:
  106. .. rst-class:: classref-method
  107. :ref:`NavigationMesh<class_NavigationMesh>` **get_mesh** **(** **)**
  108. Returns the :ref:`NavigationMesh<class_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<class_NavigationServer_method_region_set_navmesh>` API directly (as 2D uses the 3D server behind the scene).
  109. .. rst-class:: classref-item-separator
  110. ----
  111. .. _class_NavigationPolygon_method_get_outline:
  112. .. rst-class:: classref-method
  113. :ref:`PoolVector2Array<class_PoolVector2Array>` **get_outline** **(** :ref:`int<class_int>` idx **)** |const|
  114. Returns a :ref:`PoolVector2Array<class_PoolVector2Array>` containing the vertices of an outline that was created in the editor or by script.
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_NavigationPolygon_method_get_outline_count:
  118. .. rst-class:: classref-method
  119. :ref:`int<class_int>` **get_outline_count** **(** **)** |const|
  120. Returns the number of outlines that were created in the editor or by script.
  121. .. rst-class:: classref-item-separator
  122. ----
  123. .. _class_NavigationPolygon_method_get_polygon:
  124. .. rst-class:: classref-method
  125. :ref:`PoolIntArray<class_PoolIntArray>` **get_polygon** **(** :ref:`int<class_int>` idx **)**
  126. Returns a :ref:`PoolIntArray<class_PoolIntArray>` containing the indices of the vertices of a created polygon.
  127. .. rst-class:: classref-item-separator
  128. ----
  129. .. _class_NavigationPolygon_method_get_polygon_count:
  130. .. rst-class:: classref-method
  131. :ref:`int<class_int>` **get_polygon_count** **(** **)** |const|
  132. Returns the count of all polygons.
  133. .. rst-class:: classref-item-separator
  134. ----
  135. .. _class_NavigationPolygon_method_get_vertices:
  136. .. rst-class:: classref-method
  137. :ref:`PoolVector2Array<class_PoolVector2Array>` **get_vertices** **(** **)** |const|
  138. Returns a :ref:`PoolVector2Array<class_PoolVector2Array>` containing all the vertices being used to create the polygons.
  139. .. rst-class:: classref-item-separator
  140. ----
  141. .. _class_NavigationPolygon_method_make_polygons_from_outlines:
  142. .. rst-class:: classref-method
  143. void **make_polygons_from_outlines** **(** **)**
  144. Creates polygons from the outlines added in the editor or by script.
  145. .. rst-class:: classref-item-separator
  146. ----
  147. .. _class_NavigationPolygon_method_remove_outline:
  148. .. rst-class:: classref-method
  149. void **remove_outline** **(** :ref:`int<class_int>` idx **)**
  150. 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.
  151. .. rst-class:: classref-item-separator
  152. ----
  153. .. _class_NavigationPolygon_method_set_outline:
  154. .. rst-class:: classref-method
  155. void **set_outline** **(** :ref:`int<class_int>` idx, :ref:`PoolVector2Array<class_PoolVector2Array>` outline **)**
  156. 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.
  157. .. rst-class:: classref-item-separator
  158. ----
  159. .. _class_NavigationPolygon_method_set_vertices:
  160. .. rst-class:: classref-method
  161. void **set_vertices** **(** :ref:`PoolVector2Array<class_PoolVector2Array>` vertices **)**
  162. Sets the vertices that can be then indexed to create polygons with the :ref:`add_polygon<class_NavigationPolygon_method_add_polygon>` method.
  163. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  164. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  165. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  166. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`