class_navigationregion2d.rst 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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.0/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.0/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 region of the 2D navigation map.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. A region of the navigation map. It tells the :ref:`NavigationServer2D<class_NavigationServer2D>` what can be navigated and what cannot, based on its :ref:`NavigationPolygon<class_NavigationPolygon>` resource.
  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 this 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:`bool<class_bool>` | :ref:`enabled<class_NavigationRegion2D_property_enabled>` | ``true`` |
  32. +---------------------------------------------------+---------------------------------------------------------------------------------+----------+
  33. | :ref:`float<class_float>` | :ref:`enter_cost<class_NavigationRegion2D_property_enter_cost>` | ``0.0`` |
  34. +---------------------------------------------------+---------------------------------------------------------------------------------+----------+
  35. | :ref:`int<class_int>` | :ref:`navigation_layers<class_NavigationRegion2D_property_navigation_layers>` | ``1`` |
  36. +---------------------------------------------------+---------------------------------------------------------------------------------+----------+
  37. | :ref:`NavigationPolygon<class_NavigationPolygon>` | :ref:`navigation_polygon<class_NavigationRegion2D_property_navigation_polygon>` | |
  38. +---------------------------------------------------+---------------------------------------------------------------------------------+----------+
  39. | :ref:`float<class_float>` | :ref:`travel_cost<class_NavigationRegion2D_property_travel_cost>` | ``1.0`` |
  40. +---------------------------------------------------+---------------------------------------------------------------------------------+----------+
  41. .. rst-class:: classref-reftable-group
  42. Methods
  43. -------
  44. .. table::
  45. :widths: auto
  46. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`bool<class_bool>` | :ref:`get_navigation_layer_value<class_NavigationRegion2D_method_get_navigation_layer_value>` **(** :ref:`int<class_int>` layer_number **)** |const| |
  48. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`RID<class_RID>` | :ref:`get_region_rid<class_NavigationRegion2D_method_get_region_rid>` **(** **)** |const| |
  50. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`set_navigation_layer_value<class_NavigationRegion2D_method_set_navigation_layer_value>` **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)** |
  52. +-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. .. rst-class:: classref-section-separator
  54. ----
  55. .. rst-class:: classref-descriptions-group
  56. Property Descriptions
  57. ---------------------
  58. .. _class_NavigationRegion2D_property_enabled:
  59. .. rst-class:: classref-property
  60. :ref:`bool<class_bool>` **enabled** = ``true``
  61. .. rst-class:: classref-property-setget
  62. - void **set_enabled** **(** :ref:`bool<class_bool>` value **)**
  63. - :ref:`bool<class_bool>` **is_enabled** **(** **)**
  64. Determines if the **NavigationRegion2D** is enabled or disabled.
  65. .. rst-class:: classref-item-separator
  66. ----
  67. .. _class_NavigationRegion2D_property_enter_cost:
  68. .. rst-class:: classref-property
  69. :ref:`float<class_float>` **enter_cost** = ``0.0``
  70. .. rst-class:: classref-property-setget
  71. - void **set_enter_cost** **(** :ref:`float<class_float>` value **)**
  72. - :ref:`float<class_float>` **get_enter_cost** **(** **)**
  73. 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.
  74. .. rst-class:: classref-item-separator
  75. ----
  76. .. _class_NavigationRegion2D_property_navigation_layers:
  77. .. rst-class:: classref-property
  78. :ref:`int<class_int>` **navigation_layers** = ``1``
  79. .. rst-class:: classref-property-setget
  80. - void **set_navigation_layers** **(** :ref:`int<class_int>` value **)**
  81. - :ref:`int<class_int>` **get_navigation_layers** **(** **)**
  82. 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>`.
  83. .. rst-class:: classref-item-separator
  84. ----
  85. .. _class_NavigationRegion2D_property_navigation_polygon:
  86. .. rst-class:: classref-property
  87. :ref:`NavigationPolygon<class_NavigationPolygon>` **navigation_polygon**
  88. .. rst-class:: classref-property-setget
  89. - void **set_navigation_polygon** **(** :ref:`NavigationPolygon<class_NavigationPolygon>` value **)**
  90. - :ref:`NavigationPolygon<class_NavigationPolygon>` **get_navigation_polygon** **(** **)**
  91. The :ref:`NavigationPolygon<class_NavigationPolygon>` resource to use.
  92. .. rst-class:: classref-item-separator
  93. ----
  94. .. _class_NavigationRegion2D_property_travel_cost:
  95. .. rst-class:: classref-property
  96. :ref:`float<class_float>` **travel_cost** = ``1.0``
  97. .. rst-class:: classref-property-setget
  98. - void **set_travel_cost** **(** :ref:`float<class_float>` value **)**
  99. - :ref:`float<class_float>` **get_travel_cost** **(** **)**
  100. When pathfinding moves inside this region's navigation mesh the traveled distances are multiplied with ``travel_cost`` for determining the shortest path.
  101. .. rst-class:: classref-section-separator
  102. ----
  103. .. rst-class:: classref-descriptions-group
  104. Method Descriptions
  105. -------------------
  106. .. _class_NavigationRegion2D_method_get_navigation_layer_value:
  107. .. rst-class:: classref-method
  108. :ref:`bool<class_bool>` **get_navigation_layer_value** **(** :ref:`int<class_int>` layer_number **)** |const|
  109. 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.
  110. .. rst-class:: classref-item-separator
  111. ----
  112. .. _class_NavigationRegion2D_method_get_region_rid:
  113. .. rst-class:: classref-method
  114. :ref:`RID<class_RID>` **get_region_rid** **(** **)** |const|
  115. 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.
  116. .. rst-class:: classref-item-separator
  117. ----
  118. .. _class_NavigationRegion2D_method_set_navigation_layer_value:
  119. .. rst-class:: classref-method
  120. void **set_navigation_layer_value** **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)**
  121. 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.
  122. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  123. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  124. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  125. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  126. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  127. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`