class_navigationregion2d.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. A traversable 2D region that :ref:`NavigationAgent2D<class_NavigationAgent2D>`\ s can use for pathfinding.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. A traversable 2D region based on a :ref:`NavigationPolygon<class_NavigationPolygon>` that :ref:`NavigationAgent2D<class_NavigationAgent2D>`\ s can use for pathfinding.
  15. 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>`.
  16. \ **Note:** Overlapping two regions' navigation polygons is not enough for connecting two regions. They must share a similar edge.
  17. The pathfinding cost of entering a region from another region can be controlled with the :ref:`enter_cost<class_NavigationRegion2D_property_enter_cost>` value.
  18. \ **Note:** This value is not added to the path cost when the start position is already inside this region.
  19. The pathfinding cost of traveling distances inside this region can be controlled with the :ref:`travel_cost<class_NavigationRegion2D_property_travel_cost>` multiplier.
  20. \ **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.
  21. .. rst-class:: classref-introduction-group
  22. Tutorials
  23. ---------
  24. - :doc:`Using NavigationRegions <../tutorials/navigation/navigation_using_navigationregions>`
  25. .. rst-class:: classref-reftable-group
  26. Properties
  27. ----------
  28. .. table::
  29. :widths: auto
  30. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  31. | :ref:`int<class_int>` | :ref:`avoidance_layers<class_NavigationRegion2D_property_avoidance_layers>` | ``1`` |
  32. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  33. | :ref:`bool<class_bool>` | :ref:`constrain_avoidance<class_NavigationRegion2D_property_constrain_avoidance>` | ``false`` |
  34. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  35. | :ref:`bool<class_bool>` | :ref:`enabled<class_NavigationRegion2D_property_enabled>` | ``true`` |
  36. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  37. | :ref:`float<class_float>` | :ref:`enter_cost<class_NavigationRegion2D_property_enter_cost>` | ``0.0`` |
  38. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  39. | :ref:`int<class_int>` | :ref:`navigation_layers<class_NavigationRegion2D_property_navigation_layers>` | ``1`` |
  40. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  41. | :ref:`NavigationPolygon<class_NavigationPolygon>` | :ref:`navigation_polygon<class_NavigationRegion2D_property_navigation_polygon>` | |
  42. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  43. | :ref:`float<class_float>` | :ref:`travel_cost<class_NavigationRegion2D_property_travel_cost>` | ``1.0`` |
  44. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  45. | :ref:`bool<class_bool>` | :ref:`use_edge_connections<class_NavigationRegion2D_property_use_edge_connections>` | ``true`` |
  46. +---------------------------------------------------+-------------------------------------------------------------------------------------+-----------+
  47. .. rst-class:: classref-reftable-group
  48. Methods
  49. -------
  50. .. table::
  51. :widths: auto
  52. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`bool<class_bool>` | :ref:`get_avoidance_layer_value<class_NavigationRegion2D_method_get_avoidance_layer_value>` **(** :ref:`int<class_int>` layer_number **)** |const| |
  54. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`bool<class_bool>` | :ref:`get_navigation_layer_value<class_NavigationRegion2D_method_get_navigation_layer_value>` **(** :ref:`int<class_int>` layer_number **)** |const| |
  56. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`RID<class_RID>` | :ref:`get_navigation_map<class_NavigationRegion2D_method_get_navigation_map>` **(** **)** |const| |
  58. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`RID<class_RID>` | :ref:`get_region_rid<class_NavigationRegion2D_method_get_region_rid>` **(** **)** |const| |
  60. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`set_avoidance_layer_value<class_NavigationRegion2D_method_set_avoidance_layer_value>` **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)** |
  62. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | void | :ref:`set_navigation_layer_value<class_NavigationRegion2D_method_set_navigation_layer_value>` **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)** |
  64. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`set_navigation_map<class_NavigationRegion2D_method_set_navigation_map>` **(** :ref:`RID<class_RID>` navigation_map **)** |
  66. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. .. rst-class:: classref-section-separator
  68. ----
  69. .. rst-class:: classref-descriptions-group
  70. Property Descriptions
  71. ---------------------
  72. .. _class_NavigationRegion2D_property_avoidance_layers:
  73. .. rst-class:: classref-property
  74. :ref:`int<class_int>` **avoidance_layers** = ``1``
  75. .. rst-class:: classref-property-setget
  76. - void **set_avoidance_layers** **(** :ref:`int<class_int>` value **)**
  77. - :ref:`int<class_int>` **get_avoidance_layers** **(** **)**
  78. A bitfield determining all avoidance layers for the avoidance constrain.
  79. .. rst-class:: classref-item-separator
  80. ----
  81. .. _class_NavigationRegion2D_property_constrain_avoidance:
  82. .. rst-class:: classref-property
  83. :ref:`bool<class_bool>` **constrain_avoidance** = ``false``
  84. .. rst-class:: classref-property-setget
  85. - void **set_constrain_avoidance** **(** :ref:`bool<class_bool>` value **)**
  86. - :ref:`bool<class_bool>` **get_constrain_avoidance** **(** **)**
  87. 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.
  88. \ **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.
  89. .. rst-class:: classref-item-separator
  90. ----
  91. .. _class_NavigationRegion2D_property_enabled:
  92. .. rst-class:: classref-property
  93. :ref:`bool<class_bool>` **enabled** = ``true``
  94. .. rst-class:: classref-property-setget
  95. - void **set_enabled** **(** :ref:`bool<class_bool>` value **)**
  96. - :ref:`bool<class_bool>` **is_enabled** **(** **)**
  97. Determines if the **NavigationRegion2D** is enabled or disabled.
  98. .. rst-class:: classref-item-separator
  99. ----
  100. .. _class_NavigationRegion2D_property_enter_cost:
  101. .. rst-class:: classref-property
  102. :ref:`float<class_float>` **enter_cost** = ``0.0``
  103. .. rst-class:: classref-property-setget
  104. - void **set_enter_cost** **(** :ref:`float<class_float>` value **)**
  105. - :ref:`float<class_float>` **get_enter_cost** **(** **)**
  106. When pathfinding enters this region's navigation mesh from another regions navigation mesh the ``enter_cost`` value is added to the path distance for determining the shortest path.
  107. .. rst-class:: classref-item-separator
  108. ----
  109. .. _class_NavigationRegion2D_property_navigation_layers:
  110. .. rst-class:: classref-property
  111. :ref:`int<class_int>` **navigation_layers** = ``1``
  112. .. rst-class:: classref-property-setget
  113. - void **set_navigation_layers** **(** :ref:`int<class_int>` value **)**
  114. - :ref:`int<class_int>` **get_navigation_layers** **(** **)**
  115. 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>`.
  116. .. rst-class:: classref-item-separator
  117. ----
  118. .. _class_NavigationRegion2D_property_navigation_polygon:
  119. .. rst-class:: classref-property
  120. :ref:`NavigationPolygon<class_NavigationPolygon>` **navigation_polygon**
  121. .. rst-class:: classref-property-setget
  122. - void **set_navigation_polygon** **(** :ref:`NavigationPolygon<class_NavigationPolygon>` value **)**
  123. - :ref:`NavigationPolygon<class_NavigationPolygon>` **get_navigation_polygon** **(** **)**
  124. The :ref:`NavigationPolygon<class_NavigationPolygon>` resource to use.
  125. .. rst-class:: classref-item-separator
  126. ----
  127. .. _class_NavigationRegion2D_property_travel_cost:
  128. .. rst-class:: classref-property
  129. :ref:`float<class_float>` **travel_cost** = ``1.0``
  130. .. rst-class:: classref-property-setget
  131. - void **set_travel_cost** **(** :ref:`float<class_float>` value **)**
  132. - :ref:`float<class_float>` **get_travel_cost** **(** **)**
  133. When pathfinding moves inside this region's navigation mesh the traveled distances are multiplied with ``travel_cost`` for determining the shortest path.
  134. .. rst-class:: classref-item-separator
  135. ----
  136. .. _class_NavigationRegion2D_property_use_edge_connections:
  137. .. rst-class:: classref-property
  138. :ref:`bool<class_bool>` **use_edge_connections** = ``true``
  139. .. rst-class:: classref-property-setget
  140. - void **set_use_edge_connections** **(** :ref:`bool<class_bool>` value **)**
  141. - :ref:`bool<class_bool>` **get_use_edge_connections** **(** **)**
  142. If enabled the navigation region will use edge connections to connect with other navigation regions within proximity of the navigation map edge connection margin.
  143. .. rst-class:: classref-section-separator
  144. ----
  145. .. rst-class:: classref-descriptions-group
  146. Method Descriptions
  147. -------------------
  148. .. _class_NavigationRegion2D_method_get_avoidance_layer_value:
  149. .. rst-class:: classref-method
  150. :ref:`bool<class_bool>` **get_avoidance_layer_value** **(** :ref:`int<class_int>` layer_number **)** |const|
  151. 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.
  152. .. rst-class:: classref-item-separator
  153. ----
  154. .. _class_NavigationRegion2D_method_get_navigation_layer_value:
  155. .. rst-class:: classref-method
  156. :ref:`bool<class_bool>` **get_navigation_layer_value** **(** :ref:`int<class_int>` layer_number **)** |const|
  157. 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.
  158. .. rst-class:: classref-item-separator
  159. ----
  160. .. _class_NavigationRegion2D_method_get_navigation_map:
  161. .. rst-class:: classref-method
  162. :ref:`RID<class_RID>` **get_navigation_map** **(** **)** |const|
  163. Returns the current navigation map :ref:`RID<class_RID>` used by this region.
  164. .. rst-class:: classref-item-separator
  165. ----
  166. .. _class_NavigationRegion2D_method_get_region_rid:
  167. .. rst-class:: classref-method
  168. :ref:`RID<class_RID>` **get_region_rid** **(** **)** |const|
  169. 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.
  170. .. rst-class:: classref-item-separator
  171. ----
  172. .. _class_NavigationRegion2D_method_set_avoidance_layer_value:
  173. .. rst-class:: classref-method
  174. void **set_avoidance_layer_value** **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)**
  175. 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.
  176. .. rst-class:: classref-item-separator
  177. ----
  178. .. _class_NavigationRegion2D_method_set_navigation_layer_value:
  179. .. rst-class:: classref-method
  180. void **set_navigation_layer_value** **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)**
  181. 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.
  182. .. rst-class:: classref-item-separator
  183. ----
  184. .. _class_NavigationRegion2D_method_set_navigation_map:
  185. .. rst-class:: classref-method
  186. void **set_navigation_map** **(** :ref:`RID<class_RID>` navigation_map **)**
  187. 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.
  188. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  189. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  190. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  191. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  192. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  193. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  194. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`