class_navigationregion2d.rst 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  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/NavigationRegion2D.xml.
  6. .. _class_NavigationRegion2D:
  7. NavigationRegion2D
  8. ==================
  9. **Experimental:** This class may be changed or removed in future versions.
  10. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  11. A traversable 2D region that :ref:`NavigationAgent2D<class_NavigationAgent2D>`\ s can use for pathfinding.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. A traversable 2D region based on a :ref:`NavigationPolygon<class_NavigationPolygon>` that :ref:`NavigationAgent2D<class_NavigationAgent2D>`\ s can use for pathfinding.
  16. Two regions can be connected to each other if they share a similar edge. You can set the minimum distance between two vertices required to connect two edges by using :ref:`NavigationServer2D.map_set_edge_connection_margin<class_NavigationServer2D_method_map_set_edge_connection_margin>`.
  17. \ **Note:** Overlapping two regions' navigation polygons is not enough for connecting two regions. They must share a similar edge.
  18. The pathfinding cost of entering a region from another region can be controlled with the :ref:`enter_cost<class_NavigationRegion2D_property_enter_cost>` value.
  19. \ **Note:** This value is not added to the path cost when the start position is already inside this region.
  20. The pathfinding cost of traveling distances inside this region can be controlled with the :ref:`travel_cost<class_NavigationRegion2D_property_travel_cost>` multiplier.
  21. \ **Note:** This node caches changes to its properties, so if you make changes to the underlying region :ref:`RID<class_RID>` in :ref:`NavigationServer2D<class_NavigationServer2D>`, they will not be reflected in this node's properties.
  22. .. rst-class:: classref-introduction-group
  23. Tutorials
  24. ---------
  25. - :doc:`Using NavigationRegions <../tutorials/navigation/navigation_using_navigationregions>`
  26. .. rst-class:: classref-reftable-group
  27. Properties
  28. ----------
  29. .. table::
  30. :widths: auto
  31. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  32. | :ref:`int<class_int>` | :ref:`avoidance_layers<class_NavigationRegion2D_property_avoidance_layers>` | ``1`` |
  33. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  34. | :ref:`bool<class_bool>` | :ref:`constrain_avoidance<class_NavigationRegion2D_property_constrain_avoidance>` | ``false`` |
  35. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  36. | :ref:`bool<class_bool>` | :ref:`enabled<class_NavigationRegion2D_property_enabled>` | ``true`` |
  37. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  38. | :ref:`float<class_float>` | :ref:`enter_cost<class_NavigationRegion2D_property_enter_cost>` | ``0.0`` |
  39. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  40. | :ref:`int<class_int>` | :ref:`navigation_layers<class_NavigationRegion2D_property_navigation_layers>` | ``1`` |
  41. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  42. | :ref:`NavigationPolygon<class_NavigationPolygon>` | :ref:`navigation_polygon<class_NavigationRegion2D_property_navigation_polygon>` | |
  43. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  44. | :ref:`float<class_float>` | :ref:`travel_cost<class_NavigationRegion2D_property_travel_cost>` | ``1.0`` |
  45. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  46. | :ref:`bool<class_bool>` | :ref:`use_edge_connections<class_NavigationRegion2D_property_use_edge_connections>` | ``true`` |
  47. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  48. .. rst-class:: classref-reftable-group
  49. Methods
  50. -------
  51. .. table::
  52. :widths: auto
  53. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`bake_navigation_polygon<class_NavigationRegion2D_method_bake_navigation_polygon>` **(** :ref:`bool<class_bool>` on_thread=true **)** |
  55. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`bool<class_bool>` | :ref:`get_avoidance_layer_value<class_NavigationRegion2D_method_get_avoidance_layer_value>` **(** :ref:`int<class_int>` layer_number **)** |const| |
  57. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`bool<class_bool>` | :ref:`get_navigation_layer_value<class_NavigationRegion2D_method_get_navigation_layer_value>` **(** :ref:`int<class_int>` layer_number **)** |const| |
  59. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`RID<class_RID>` | :ref:`get_navigation_map<class_NavigationRegion2D_method_get_navigation_map>` **(** **)** |const| |
  61. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`RID<class_RID>` | :ref:`get_region_rid<class_NavigationRegion2D_method_get_region_rid>` **(** **)** |const| |
  63. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`RID<class_RID>` | :ref:`get_rid<class_NavigationRegion2D_method_get_rid>` **(** **)** |const| |
  65. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`bool<class_bool>` | :ref:`is_baking<class_NavigationRegion2D_method_is_baking>` **(** **)** |const| |
  67. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`set_avoidance_layer_value<class_NavigationRegion2D_method_set_avoidance_layer_value>` **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)** |
  69. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | void | :ref:`set_navigation_layer_value<class_NavigationRegion2D_method_set_navigation_layer_value>` **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)** |
  71. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | void | :ref:`set_navigation_map<class_NavigationRegion2D_method_set_navigation_map>` **(** :ref:`RID<class_RID>` navigation_map **)** |
  73. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. .. rst-class:: classref-section-separator
  75. ----
  76. .. rst-class:: classref-descriptions-group
  77. Signals
  78. -------
  79. .. _class_NavigationRegion2D_signal_bake_finished:
  80. .. rst-class:: classref-signal
  81. **bake_finished** **(** **)**
  82. Emitted when a navigation polygon bake operation is completed.
  83. .. rst-class:: classref-item-separator
  84. ----
  85. .. _class_NavigationRegion2D_signal_navigation_polygon_changed:
  86. .. rst-class:: classref-signal
  87. **navigation_polygon_changed** **(** **)**
  88. Emitted when the used navigation polygon is replaced or changes to the internals of the current navigation polygon are committed.
  89. .. rst-class:: classref-section-separator
  90. ----
  91. .. rst-class:: classref-descriptions-group
  92. Property Descriptions
  93. ---------------------
  94. .. _class_NavigationRegion2D_property_avoidance_layers:
  95. .. rst-class:: classref-property
  96. :ref:`int<class_int>` **avoidance_layers** = ``1``
  97. .. rst-class:: classref-property-setget
  98. - void **set_avoidance_layers** **(** :ref:`int<class_int>` value **)**
  99. - :ref:`int<class_int>` **get_avoidance_layers** **(** **)**
  100. A bitfield determining all avoidance layers for the avoidance constrain.
  101. .. rst-class:: classref-item-separator
  102. ----
  103. .. _class_NavigationRegion2D_property_constrain_avoidance:
  104. .. rst-class:: classref-property
  105. :ref:`bool<class_bool>` **constrain_avoidance** = ``false``
  106. .. rst-class:: classref-property-setget
  107. - void **set_constrain_avoidance** **(** :ref:`bool<class_bool>` value **)**
  108. - :ref:`bool<class_bool>` **get_constrain_avoidance** **(** **)**
  109. If ``true`` constraints avoidance agent's with an avoidance mask bit that matches with a bit of the :ref:`avoidance_layers<class_NavigationRegion2D_property_avoidance_layers>` to the navigation polygon. Due to each navigation polygon outline creating an obstacle and each polygon edge creating an avoidance line constrain keep the navigation polygon shape as simple as possible for performance.
  110. \ **Experimental:** This is an experimental feature and should not be used in production as agent's can get stuck on the navigation polygon corners and edges especially at high frame rate.
  111. .. rst-class:: classref-item-separator
  112. ----
  113. .. _class_NavigationRegion2D_property_enabled:
  114. .. rst-class:: classref-property
  115. :ref:`bool<class_bool>` **enabled** = ``true``
  116. .. rst-class:: classref-property-setget
  117. - void **set_enabled** **(** :ref:`bool<class_bool>` value **)**
  118. - :ref:`bool<class_bool>` **is_enabled** **(** **)**
  119. Determines if the **NavigationRegion2D** is enabled or disabled.
  120. .. rst-class:: classref-item-separator
  121. ----
  122. .. _class_NavigationRegion2D_property_enter_cost:
  123. .. rst-class:: classref-property
  124. :ref:`float<class_float>` **enter_cost** = ``0.0``
  125. .. rst-class:: classref-property-setget
  126. - void **set_enter_cost** **(** :ref:`float<class_float>` value **)**
  127. - :ref:`float<class_float>` **get_enter_cost** **(** **)**
  128. When pathfinding enters this region's navigation mesh from another regions navigation mesh the :ref:`enter_cost<class_NavigationRegion2D_property_enter_cost>` value is added to the path distance for determining the shortest path.
  129. .. rst-class:: classref-item-separator
  130. ----
  131. .. _class_NavigationRegion2D_property_navigation_layers:
  132. .. rst-class:: classref-property
  133. :ref:`int<class_int>` **navigation_layers** = ``1``
  134. .. rst-class:: classref-property-setget
  135. - void **set_navigation_layers** **(** :ref:`int<class_int>` value **)**
  136. - :ref:`int<class_int>` **get_navigation_layers** **(** **)**
  137. A bitfield determining all navigation layers the region belongs to. These navigation layers can be checked upon when requesting a path with :ref:`NavigationServer2D.map_get_path<class_NavigationServer2D_method_map_get_path>`.
  138. .. rst-class:: classref-item-separator
  139. ----
  140. .. _class_NavigationRegion2D_property_navigation_polygon:
  141. .. rst-class:: classref-property
  142. :ref:`NavigationPolygon<class_NavigationPolygon>` **navigation_polygon**
  143. .. rst-class:: classref-property-setget
  144. - void **set_navigation_polygon** **(** :ref:`NavigationPolygon<class_NavigationPolygon>` value **)**
  145. - :ref:`NavigationPolygon<class_NavigationPolygon>` **get_navigation_polygon** **(** **)**
  146. The :ref:`NavigationPolygon<class_NavigationPolygon>` resource to use.
  147. .. rst-class:: classref-item-separator
  148. ----
  149. .. _class_NavigationRegion2D_property_travel_cost:
  150. .. rst-class:: classref-property
  151. :ref:`float<class_float>` **travel_cost** = ``1.0``
  152. .. rst-class:: classref-property-setget
  153. - void **set_travel_cost** **(** :ref:`float<class_float>` value **)**
  154. - :ref:`float<class_float>` **get_travel_cost** **(** **)**
  155. When pathfinding moves inside this region's navigation mesh the traveled distances are multiplied with :ref:`travel_cost<class_NavigationRegion2D_property_travel_cost>` for determining the shortest path.
  156. .. rst-class:: classref-item-separator
  157. ----
  158. .. _class_NavigationRegion2D_property_use_edge_connections:
  159. .. rst-class:: classref-property
  160. :ref:`bool<class_bool>` **use_edge_connections** = ``true``
  161. .. rst-class:: classref-property-setget
  162. - void **set_use_edge_connections** **(** :ref:`bool<class_bool>` value **)**
  163. - :ref:`bool<class_bool>` **get_use_edge_connections** **(** **)**
  164. If enabled the navigation region will use edge connections to connect with other navigation regions within proximity of the navigation map edge connection margin.
  165. .. rst-class:: classref-section-separator
  166. ----
  167. .. rst-class:: classref-descriptions-group
  168. Method Descriptions
  169. -------------------
  170. .. _class_NavigationRegion2D_method_bake_navigation_polygon:
  171. .. rst-class:: classref-method
  172. void **bake_navigation_polygon** **(** :ref:`bool<class_bool>` on_thread=true **)**
  173. Bakes the :ref:`NavigationPolygon<class_NavigationPolygon>`. If ``on_thread`` is set to ``true`` (default), the baking is done on a separate thread.
  174. .. rst-class:: classref-item-separator
  175. ----
  176. .. _class_NavigationRegion2D_method_get_avoidance_layer_value:
  177. .. rst-class:: classref-method
  178. :ref:`bool<class_bool>` **get_avoidance_layer_value** **(** :ref:`int<class_int>` layer_number **)** |const|
  179. Returns whether or not the specified layer of the :ref:`avoidance_layers<class_NavigationRegion2D_property_avoidance_layers>` bitmask is enabled, given a ``layer_number`` between 1 and 32.
  180. .. rst-class:: classref-item-separator
  181. ----
  182. .. _class_NavigationRegion2D_method_get_navigation_layer_value:
  183. .. rst-class:: classref-method
  184. :ref:`bool<class_bool>` **get_navigation_layer_value** **(** :ref:`int<class_int>` layer_number **)** |const|
  185. Returns whether or not the specified layer of the :ref:`navigation_layers<class_NavigationRegion2D_property_navigation_layers>` bitmask is enabled, given a ``layer_number`` between 1 and 32.
  186. .. rst-class:: classref-item-separator
  187. ----
  188. .. _class_NavigationRegion2D_method_get_navigation_map:
  189. .. rst-class:: classref-method
  190. :ref:`RID<class_RID>` **get_navigation_map** **(** **)** |const|
  191. Returns the current navigation map :ref:`RID<class_RID>` used by this region.
  192. .. rst-class:: classref-item-separator
  193. ----
  194. .. _class_NavigationRegion2D_method_get_region_rid:
  195. .. rst-class:: classref-method
  196. :ref:`RID<class_RID>` **get_region_rid** **(** **)** |const|
  197. **Deprecated:** Use :ref:`get_rid<class_NavigationRegion2D_method_get_rid>` instead.
  198. Returns the :ref:`RID<class_RID>` of this region on the :ref:`NavigationServer2D<class_NavigationServer2D>`.
  199. .. rst-class:: classref-item-separator
  200. ----
  201. .. _class_NavigationRegion2D_method_get_rid:
  202. .. rst-class:: classref-method
  203. :ref:`RID<class_RID>` **get_rid** **(** **)** |const|
  204. Returns the :ref:`RID<class_RID>` of this region on the :ref:`NavigationServer2D<class_NavigationServer2D>`. Combined with :ref:`NavigationServer2D.map_get_closest_point_owner<class_NavigationServer2D_method_map_get_closest_point_owner>` can be used to identify the **NavigationRegion2D** closest to a point on the merged navigation map.
  205. .. rst-class:: classref-item-separator
  206. ----
  207. .. _class_NavigationRegion2D_method_is_baking:
  208. .. rst-class:: classref-method
  209. :ref:`bool<class_bool>` **is_baking** **(** **)** |const|
  210. Returns ``true`` when the :ref:`NavigationPolygon<class_NavigationPolygon>` is being baked on a background thread.
  211. .. rst-class:: classref-item-separator
  212. ----
  213. .. _class_NavigationRegion2D_method_set_avoidance_layer_value:
  214. .. rst-class:: classref-method
  215. void **set_avoidance_layer_value** **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)**
  216. Based on ``value``, enables or disables the specified layer in the :ref:`avoidance_layers<class_NavigationRegion2D_property_avoidance_layers>` bitmask, given a ``layer_number`` between 1 and 32.
  217. .. rst-class:: classref-item-separator
  218. ----
  219. .. _class_NavigationRegion2D_method_set_navigation_layer_value:
  220. .. rst-class:: classref-method
  221. void **set_navigation_layer_value** **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)**
  222. Based on ``value``, enables or disables the specified layer in the :ref:`navigation_layers<class_NavigationRegion2D_property_navigation_layers>` bitmask, given a ``layer_number`` between 1 and 32.
  223. .. rst-class:: classref-item-separator
  224. ----
  225. .. _class_NavigationRegion2D_method_set_navigation_map:
  226. .. rst-class:: classref-method
  227. void **set_navigation_map** **(** :ref:`RID<class_RID>` navigation_map **)**
  228. Sets the :ref:`RID<class_RID>` of the navigation map this region should use. By default the region will automatically join the :ref:`World2D<class_World2D>` default navigation map so this function is only required to override the default map.
  229. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  230. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  231. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  232. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  233. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  234. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  235. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`