class_navigationserver2d.rst 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020
  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/NavigationServer2D.xml.
  6. .. _class_NavigationServer2D:
  7. NavigationServer2D
  8. ==================
  9. **Inherits:** :ref:`Object<class_Object>`
  10. Server interface for low-level 2D navigation access
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. NavigationServer2D is the server responsible for all 2D navigation. It handles several objects, namely maps, regions and agents.
  15. Maps are made up of regions, which are made of navigation polygons. Together, they define the navigable areas in the 2D world.
  16. \ **Note:** Most NavigationServer changes take effect after the next physics frame and not immediately. This includes all changes made to maps, regions or agents by navigation related Nodes in the SceneTree or made through scripts.
  17. For two regions to be connected to each other, they must share a similar edge. An edge is considered connected to another if both of its two vertices are at a distance less than ``edge_connection_margin`` to the respective other edge's vertex.
  18. You may assign navigation layers to regions with :ref:`region_set_navigation_layers<class_NavigationServer2D_method_region_set_navigation_layers>`, which then can be checked upon when requesting a path with :ref:`map_get_path<class_NavigationServer2D_method_map_get_path>`. This allows allowing or forbidding some areas to 2D objects.
  19. To use the collision avoidance system, you may use agents. You can set an agent's target velocity, then the servers will emit a callback with a modified velocity.
  20. \ **Note:** The collision avoidance system ignores regions. Using the modified velocity as-is might lead to pushing and agent outside of a navigable area. This is a limitation of the collision avoidance system, any more complex situation may require the use of the physics engine.
  21. This server keeps tracks of any call and executes them during the sync phase. This means that you can request any change to the map, using any thread, without worrying.
  22. .. rst-class:: classref-introduction-group
  23. Tutorials
  24. ---------
  25. - `2D Navigation Demo <https://godotengine.org/asset-library/asset/117>`__
  26. - :doc:`Using NavigationServer <../tutorials/navigation/navigation_using_navigationservers>`
  27. .. rst-class:: classref-reftable-group
  28. Methods
  29. -------
  30. .. table::
  31. :widths: auto
  32. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`RID<class_RID>` | :ref:`agent_create<class_NavigationServer2D_method_agent_create>` **(** **)** |
  34. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`RID<class_RID>` | :ref:`agent_get_map<class_NavigationServer2D_method_agent_get_map>` **(** :ref:`RID<class_RID>` agent **)** |const| |
  36. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`bool<class_bool>` | :ref:`agent_is_map_changed<class_NavigationServer2D_method_agent_is_map_changed>` **(** :ref:`RID<class_RID>` agent **)** |const| |
  38. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`agent_set_callback<class_NavigationServer2D_method_agent_set_callback>` **(** :ref:`RID<class_RID>` agent, :ref:`int<class_int>` object_id, :ref:`StringName<class_StringName>` method, :ref:`Variant<class_Variant>` userdata=null **)** |
  40. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`agent_set_map<class_NavigationServer2D_method_agent_set_map>` **(** :ref:`RID<class_RID>` agent, :ref:`RID<class_RID>` map **)** |
  42. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`agent_set_max_neighbors<class_NavigationServer2D_method_agent_set_max_neighbors>` **(** :ref:`RID<class_RID>` agent, :ref:`int<class_int>` count **)** |
  44. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | void | :ref:`agent_set_max_speed<class_NavigationServer2D_method_agent_set_max_speed>` **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` max_speed **)** |
  46. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | void | :ref:`agent_set_neighbor_distance<class_NavigationServer2D_method_agent_set_neighbor_distance>` **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` distance **)** |
  48. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`agent_set_position<class_NavigationServer2D_method_agent_set_position>` **(** :ref:`RID<class_RID>` agent, :ref:`Vector2<class_Vector2>` position **)** |
  50. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | void | :ref:`agent_set_radius<class_NavigationServer2D_method_agent_set_radius>` **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` radius **)** |
  52. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | void | :ref:`agent_set_target_velocity<class_NavigationServer2D_method_agent_set_target_velocity>` **(** :ref:`RID<class_RID>` agent, :ref:`Vector2<class_Vector2>` target_velocity **)** |
  54. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | void | :ref:`agent_set_time_horizon<class_NavigationServer2D_method_agent_set_time_horizon>` **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` time **)** |
  56. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | void | :ref:`agent_set_velocity<class_NavigationServer2D_method_agent_set_velocity>` **(** :ref:`RID<class_RID>` agent, :ref:`Vector2<class_Vector2>` velocity **)** |
  58. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`free_rid<class_NavigationServer2D_method_free_rid>` **(** :ref:`RID<class_RID>` rid **)** |
  60. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`RID[]<class_RID>` | :ref:`get_maps<class_NavigationServer2D_method_get_maps>` **(** **)** |const| |
  62. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`RID<class_RID>` | :ref:`link_create<class_NavigationServer2D_method_link_create>` **(** **)** |
  64. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`Vector2<class_Vector2>` | :ref:`link_get_end_position<class_NavigationServer2D_method_link_get_end_position>` **(** :ref:`RID<class_RID>` link **)** |const| |
  66. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`float<class_float>` | :ref:`link_get_enter_cost<class_NavigationServer2D_method_link_get_enter_cost>` **(** :ref:`RID<class_RID>` link **)** |const| |
  68. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`RID<class_RID>` | :ref:`link_get_map<class_NavigationServer2D_method_link_get_map>` **(** :ref:`RID<class_RID>` link **)** |const| |
  70. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`int<class_int>` | :ref:`link_get_navigation_layers<class_NavigationServer2D_method_link_get_navigation_layers>` **(** :ref:`RID<class_RID>` link **)** |const| |
  72. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`int<class_int>` | :ref:`link_get_owner_id<class_NavigationServer2D_method_link_get_owner_id>` **(** :ref:`RID<class_RID>` link **)** |const| |
  74. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`Vector2<class_Vector2>` | :ref:`link_get_start_position<class_NavigationServer2D_method_link_get_start_position>` **(** :ref:`RID<class_RID>` link **)** |const| |
  76. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`float<class_float>` | :ref:`link_get_travel_cost<class_NavigationServer2D_method_link_get_travel_cost>` **(** :ref:`RID<class_RID>` link **)** |const| |
  78. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`bool<class_bool>` | :ref:`link_is_bidirectional<class_NavigationServer2D_method_link_is_bidirectional>` **(** :ref:`RID<class_RID>` link **)** |const| |
  80. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | void | :ref:`link_set_bidirectional<class_NavigationServer2D_method_link_set_bidirectional>` **(** :ref:`RID<class_RID>` link, :ref:`bool<class_bool>` bidirectional **)** |
  82. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`link_set_end_position<class_NavigationServer2D_method_link_set_end_position>` **(** :ref:`RID<class_RID>` link, :ref:`Vector2<class_Vector2>` position **)** |
  84. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`link_set_enter_cost<class_NavigationServer2D_method_link_set_enter_cost>` **(** :ref:`RID<class_RID>` link, :ref:`float<class_float>` enter_cost **)** |
  86. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`link_set_map<class_NavigationServer2D_method_link_set_map>` **(** :ref:`RID<class_RID>` link, :ref:`RID<class_RID>` map **)** |
  88. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`link_set_navigation_layers<class_NavigationServer2D_method_link_set_navigation_layers>` **(** :ref:`RID<class_RID>` link, :ref:`int<class_int>` navigation_layers **)** |
  90. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`link_set_owner_id<class_NavigationServer2D_method_link_set_owner_id>` **(** :ref:`RID<class_RID>` link, :ref:`int<class_int>` owner_id **)** |
  92. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`link_set_start_position<class_NavigationServer2D_method_link_set_start_position>` **(** :ref:`RID<class_RID>` link, :ref:`Vector2<class_Vector2>` position **)** |
  94. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | void | :ref:`link_set_travel_cost<class_NavigationServer2D_method_link_set_travel_cost>` **(** :ref:`RID<class_RID>` link, :ref:`float<class_float>` travel_cost **)** |
  96. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | :ref:`RID<class_RID>` | :ref:`map_create<class_NavigationServer2D_method_map_create>` **(** **)** |
  98. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | void | :ref:`map_force_update<class_NavigationServer2D_method_map_force_update>` **(** :ref:`RID<class_RID>` map **)** |
  100. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`RID[]<class_RID>` | :ref:`map_get_agents<class_NavigationServer2D_method_map_get_agents>` **(** :ref:`RID<class_RID>` map **)** |const| |
  102. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | :ref:`float<class_float>` | :ref:`map_get_cell_size<class_NavigationServer2D_method_map_get_cell_size>` **(** :ref:`RID<class_RID>` map **)** |const| |
  104. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | :ref:`Vector2<class_Vector2>` | :ref:`map_get_closest_point<class_NavigationServer2D_method_map_get_closest_point>` **(** :ref:`RID<class_RID>` map, :ref:`Vector2<class_Vector2>` to_point **)** |const| |
  106. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | :ref:`RID<class_RID>` | :ref:`map_get_closest_point_owner<class_NavigationServer2D_method_map_get_closest_point_owner>` **(** :ref:`RID<class_RID>` map, :ref:`Vector2<class_Vector2>` to_point **)** |const| |
  108. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | :ref:`float<class_float>` | :ref:`map_get_edge_connection_margin<class_NavigationServer2D_method_map_get_edge_connection_margin>` **(** :ref:`RID<class_RID>` map **)** |const| |
  110. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | :ref:`float<class_float>` | :ref:`map_get_link_connection_radius<class_NavigationServer2D_method_map_get_link_connection_radius>` **(** :ref:`RID<class_RID>` map **)** |const| |
  112. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | :ref:`RID[]<class_RID>` | :ref:`map_get_links<class_NavigationServer2D_method_map_get_links>` **(** :ref:`RID<class_RID>` map **)** |const| |
  114. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | :ref:`PackedVector2Array<class_PackedVector2Array>` | :ref:`map_get_path<class_NavigationServer2D_method_map_get_path>` **(** :ref:`RID<class_RID>` map, :ref:`Vector2<class_Vector2>` origin, :ref:`Vector2<class_Vector2>` destination, :ref:`bool<class_bool>` optimize, :ref:`int<class_int>` navigation_layers=1 **)** |const| |
  116. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | :ref:`RID[]<class_RID>` | :ref:`map_get_regions<class_NavigationServer2D_method_map_get_regions>` **(** :ref:`RID<class_RID>` map **)** |const| |
  118. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | :ref:`bool<class_bool>` | :ref:`map_is_active<class_NavigationServer2D_method_map_is_active>` **(** :ref:`RID<class_RID>` map **)** |const| |
  120. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | void | :ref:`map_set_active<class_NavigationServer2D_method_map_set_active>` **(** :ref:`RID<class_RID>` map, :ref:`bool<class_bool>` active **)** |
  122. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | void | :ref:`map_set_cell_size<class_NavigationServer2D_method_map_set_cell_size>` **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` cell_size **)** |
  124. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | void | :ref:`map_set_edge_connection_margin<class_NavigationServer2D_method_map_set_edge_connection_margin>` **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` margin **)** |
  126. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | void | :ref:`map_set_link_connection_radius<class_NavigationServer2D_method_map_set_link_connection_radius>` **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` radius **)** |
  128. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | void | :ref:`query_path<class_NavigationServer2D_method_query_path>` **(** :ref:`NavigationPathQueryParameters2D<class_NavigationPathQueryParameters2D>` parameters, :ref:`NavigationPathQueryResult2D<class_NavigationPathQueryResult2D>` result **)** |const| |
  130. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. | :ref:`RID<class_RID>` | :ref:`region_create<class_NavigationServer2D_method_region_create>` **(** **)** |
  132. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  133. | :ref:`Vector2<class_Vector2>` | :ref:`region_get_connection_pathway_end<class_NavigationServer2D_method_region_get_connection_pathway_end>` **(** :ref:`RID<class_RID>` region, :ref:`int<class_int>` connection **)** |const| |
  134. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  135. | :ref:`Vector2<class_Vector2>` | :ref:`region_get_connection_pathway_start<class_NavigationServer2D_method_region_get_connection_pathway_start>` **(** :ref:`RID<class_RID>` region, :ref:`int<class_int>` connection **)** |const| |
  136. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  137. | :ref:`int<class_int>` | :ref:`region_get_connections_count<class_NavigationServer2D_method_region_get_connections_count>` **(** :ref:`RID<class_RID>` region **)** |const| |
  138. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  139. | :ref:`float<class_float>` | :ref:`region_get_enter_cost<class_NavigationServer2D_method_region_get_enter_cost>` **(** :ref:`RID<class_RID>` region **)** |const| |
  140. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  141. | :ref:`RID<class_RID>` | :ref:`region_get_map<class_NavigationServer2D_method_region_get_map>` **(** :ref:`RID<class_RID>` region **)** |const| |
  142. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  143. | :ref:`int<class_int>` | :ref:`region_get_navigation_layers<class_NavigationServer2D_method_region_get_navigation_layers>` **(** :ref:`RID<class_RID>` region **)** |const| |
  144. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  145. | :ref:`int<class_int>` | :ref:`region_get_owner_id<class_NavigationServer2D_method_region_get_owner_id>` **(** :ref:`RID<class_RID>` region **)** |const| |
  146. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  147. | :ref:`float<class_float>` | :ref:`region_get_travel_cost<class_NavigationServer2D_method_region_get_travel_cost>` **(** :ref:`RID<class_RID>` region **)** |const| |
  148. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  149. | :ref:`bool<class_bool>` | :ref:`region_owns_point<class_NavigationServer2D_method_region_owns_point>` **(** :ref:`RID<class_RID>` region, :ref:`Vector2<class_Vector2>` point **)** |const| |
  150. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  151. | void | :ref:`region_set_enter_cost<class_NavigationServer2D_method_region_set_enter_cost>` **(** :ref:`RID<class_RID>` region, :ref:`float<class_float>` enter_cost **)** |
  152. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  153. | void | :ref:`region_set_map<class_NavigationServer2D_method_region_set_map>` **(** :ref:`RID<class_RID>` region, :ref:`RID<class_RID>` map **)** |
  154. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  155. | void | :ref:`region_set_navigation_layers<class_NavigationServer2D_method_region_set_navigation_layers>` **(** :ref:`RID<class_RID>` region, :ref:`int<class_int>` navigation_layers **)** |
  156. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  157. | void | :ref:`region_set_navigation_polygon<class_NavigationServer2D_method_region_set_navigation_polygon>` **(** :ref:`RID<class_RID>` region, :ref:`NavigationPolygon<class_NavigationPolygon>` navigation_polygon **)** |
  158. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  159. | void | :ref:`region_set_owner_id<class_NavigationServer2D_method_region_set_owner_id>` **(** :ref:`RID<class_RID>` region, :ref:`int<class_int>` owner_id **)** |
  160. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  161. | void | :ref:`region_set_transform<class_NavigationServer2D_method_region_set_transform>` **(** :ref:`RID<class_RID>` region, :ref:`Transform2D<class_Transform2D>` transform **)** |
  162. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  163. | void | :ref:`region_set_travel_cost<class_NavigationServer2D_method_region_set_travel_cost>` **(** :ref:`RID<class_RID>` region, :ref:`float<class_float>` travel_cost **)** |
  164. +-----------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  165. .. rst-class:: classref-section-separator
  166. ----
  167. .. rst-class:: classref-descriptions-group
  168. Signals
  169. -------
  170. .. _class_NavigationServer2D_signal_map_changed:
  171. .. rst-class:: classref-signal
  172. **map_changed** **(** :ref:`RID<class_RID>` map **)**
  173. Emitted when a navigation map is updated, when a region moves or is modified.
  174. .. rst-class:: classref-section-separator
  175. ----
  176. .. rst-class:: classref-descriptions-group
  177. Method Descriptions
  178. -------------------
  179. .. _class_NavigationServer2D_method_agent_create:
  180. .. rst-class:: classref-method
  181. :ref:`RID<class_RID>` **agent_create** **(** **)**
  182. Creates the agent.
  183. .. rst-class:: classref-item-separator
  184. ----
  185. .. _class_NavigationServer2D_method_agent_get_map:
  186. .. rst-class:: classref-method
  187. :ref:`RID<class_RID>` **agent_get_map** **(** :ref:`RID<class_RID>` agent **)** |const|
  188. Returns the navigation map :ref:`RID<class_RID>` the requested ``agent`` is currently assigned to.
  189. .. rst-class:: classref-item-separator
  190. ----
  191. .. _class_NavigationServer2D_method_agent_is_map_changed:
  192. .. rst-class:: classref-method
  193. :ref:`bool<class_bool>` **agent_is_map_changed** **(** :ref:`RID<class_RID>` agent **)** |const|
  194. Returns true if the map got changed the previous frame.
  195. .. rst-class:: classref-item-separator
  196. ----
  197. .. _class_NavigationServer2D_method_agent_set_callback:
  198. .. rst-class:: classref-method
  199. void **agent_set_callback** **(** :ref:`RID<class_RID>` agent, :ref:`int<class_int>` object_id, :ref:`StringName<class_StringName>` method, :ref:`Variant<class_Variant>` userdata=null **)**
  200. Sets the callback ``object_id`` and ``method`` that gets called after each avoidance processing step for the ``agent``. The calculated ``safe_velocity`` will be dispatched with a signal to the object just before the physics calculations.
  201. \ **Note:** Created callbacks are always processed independently of the SceneTree state as long as the agent is on a navigation map and not freed. To disable the dispatch of a callback from an agent use :ref:`agent_set_callback<class_NavigationServer2D_method_agent_set_callback>` again with a ``0`` ObjectID as the ``object_id``.
  202. .. rst-class:: classref-item-separator
  203. ----
  204. .. _class_NavigationServer2D_method_agent_set_map:
  205. .. rst-class:: classref-method
  206. void **agent_set_map** **(** :ref:`RID<class_RID>` agent, :ref:`RID<class_RID>` map **)**
  207. Puts the agent in the map.
  208. .. rst-class:: classref-item-separator
  209. ----
  210. .. _class_NavigationServer2D_method_agent_set_max_neighbors:
  211. .. rst-class:: classref-method
  212. void **agent_set_max_neighbors** **(** :ref:`RID<class_RID>` agent, :ref:`int<class_int>` count **)**
  213. Sets the maximum number of other agents the agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe.
  214. .. rst-class:: classref-item-separator
  215. ----
  216. .. _class_NavigationServer2D_method_agent_set_max_speed:
  217. .. rst-class:: classref-method
  218. void **agent_set_max_speed** **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` max_speed **)**
  219. Sets the maximum speed of the agent. Must be positive.
  220. .. rst-class:: classref-item-separator
  221. ----
  222. .. _class_NavigationServer2D_method_agent_set_neighbor_distance:
  223. .. rst-class:: classref-method
  224. void **agent_set_neighbor_distance** **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` distance **)**
  225. Sets the maximum distance to other agents this agent takes into account in the navigation. The larger this number, the longer the running time of the simulation. If the number is too low, the simulation will not be safe.
  226. .. rst-class:: classref-item-separator
  227. ----
  228. .. _class_NavigationServer2D_method_agent_set_position:
  229. .. rst-class:: classref-method
  230. void **agent_set_position** **(** :ref:`RID<class_RID>` agent, :ref:`Vector2<class_Vector2>` position **)**
  231. Sets the position of the agent in world space.
  232. .. rst-class:: classref-item-separator
  233. ----
  234. .. _class_NavigationServer2D_method_agent_set_radius:
  235. .. rst-class:: classref-method
  236. void **agent_set_radius** **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` radius **)**
  237. Sets the radius of the agent.
  238. .. rst-class:: classref-item-separator
  239. ----
  240. .. _class_NavigationServer2D_method_agent_set_target_velocity:
  241. .. rst-class:: classref-method
  242. void **agent_set_target_velocity** **(** :ref:`RID<class_RID>` agent, :ref:`Vector2<class_Vector2>` target_velocity **)**
  243. Sets the new target velocity.
  244. .. rst-class:: classref-item-separator
  245. ----
  246. .. _class_NavigationServer2D_method_agent_set_time_horizon:
  247. .. rst-class:: classref-method
  248. void **agent_set_time_horizon** **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` time **)**
  249. The minimal amount of time for which the agent's velocities that are computed by the simulation are safe with respect to other agents. The larger this number, the sooner this agent will respond to the presence of other agents, but the less freedom this agent has in choosing its velocities. Must be positive.
  250. .. rst-class:: classref-item-separator
  251. ----
  252. .. _class_NavigationServer2D_method_agent_set_velocity:
  253. .. rst-class:: classref-method
  254. void **agent_set_velocity** **(** :ref:`RID<class_RID>` agent, :ref:`Vector2<class_Vector2>` velocity **)**
  255. Sets the current velocity of the agent.
  256. .. rst-class:: classref-item-separator
  257. ----
  258. .. _class_NavigationServer2D_method_free_rid:
  259. .. rst-class:: classref-method
  260. void **free_rid** **(** :ref:`RID<class_RID>` rid **)**
  261. Destroys the given RID.
  262. .. rst-class:: classref-item-separator
  263. ----
  264. .. _class_NavigationServer2D_method_get_maps:
  265. .. rst-class:: classref-method
  266. :ref:`RID[]<class_RID>` **get_maps** **(** **)** |const|
  267. Returns all created navigation map :ref:`RID<class_RID>`\ s on the NavigationServer. This returns both 2D and 3D created navigation maps as there is technically no distinction between them.
  268. .. rst-class:: classref-item-separator
  269. ----
  270. .. _class_NavigationServer2D_method_link_create:
  271. .. rst-class:: classref-method
  272. :ref:`RID<class_RID>` **link_create** **(** **)**
  273. Create a new link between two positions on a map.
  274. .. rst-class:: classref-item-separator
  275. ----
  276. .. _class_NavigationServer2D_method_link_get_end_position:
  277. .. rst-class:: classref-method
  278. :ref:`Vector2<class_Vector2>` **link_get_end_position** **(** :ref:`RID<class_RID>` link **)** |const|
  279. Returns the ending position of this ``link``.
  280. .. rst-class:: classref-item-separator
  281. ----
  282. .. _class_NavigationServer2D_method_link_get_enter_cost:
  283. .. rst-class:: classref-method
  284. :ref:`float<class_float>` **link_get_enter_cost** **(** :ref:`RID<class_RID>` link **)** |const|
  285. Returns the ``enter_cost`` of this ``link``.
  286. .. rst-class:: classref-item-separator
  287. ----
  288. .. _class_NavigationServer2D_method_link_get_map:
  289. .. rst-class:: classref-method
  290. :ref:`RID<class_RID>` **link_get_map** **(** :ref:`RID<class_RID>` link **)** |const|
  291. Returns the navigation map :ref:`RID<class_RID>` the requested ``link`` is currently assigned to.
  292. .. rst-class:: classref-item-separator
  293. ----
  294. .. _class_NavigationServer2D_method_link_get_navigation_layers:
  295. .. rst-class:: classref-method
  296. :ref:`int<class_int>` **link_get_navigation_layers** **(** :ref:`RID<class_RID>` link **)** |const|
  297. Returns the navigation layers for this ``link``.
  298. .. rst-class:: classref-item-separator
  299. ----
  300. .. _class_NavigationServer2D_method_link_get_owner_id:
  301. .. rst-class:: classref-method
  302. :ref:`int<class_int>` **link_get_owner_id** **(** :ref:`RID<class_RID>` link **)** |const|
  303. Returns the ``ObjectID`` of the object which manages this link.
  304. .. rst-class:: classref-item-separator
  305. ----
  306. .. _class_NavigationServer2D_method_link_get_start_position:
  307. .. rst-class:: classref-method
  308. :ref:`Vector2<class_Vector2>` **link_get_start_position** **(** :ref:`RID<class_RID>` link **)** |const|
  309. Returns the starting position of this ``link``.
  310. .. rst-class:: classref-item-separator
  311. ----
  312. .. _class_NavigationServer2D_method_link_get_travel_cost:
  313. .. rst-class:: classref-method
  314. :ref:`float<class_float>` **link_get_travel_cost** **(** :ref:`RID<class_RID>` link **)** |const|
  315. Returns the ``travel_cost`` of this ``link``.
  316. .. rst-class:: classref-item-separator
  317. ----
  318. .. _class_NavigationServer2D_method_link_is_bidirectional:
  319. .. rst-class:: classref-method
  320. :ref:`bool<class_bool>` **link_is_bidirectional** **(** :ref:`RID<class_RID>` link **)** |const|
  321. Returns whether this ``link`` can be travelled in both directions.
  322. .. rst-class:: classref-item-separator
  323. ----
  324. .. _class_NavigationServer2D_method_link_set_bidirectional:
  325. .. rst-class:: classref-method
  326. void **link_set_bidirectional** **(** :ref:`RID<class_RID>` link, :ref:`bool<class_bool>` bidirectional **)**
  327. Sets whether this ``link`` can be travelled in both directions.
  328. .. rst-class:: classref-item-separator
  329. ----
  330. .. _class_NavigationServer2D_method_link_set_end_position:
  331. .. rst-class:: classref-method
  332. void **link_set_end_position** **(** :ref:`RID<class_RID>` link, :ref:`Vector2<class_Vector2>` position **)**
  333. Sets the exit position for the ``link``.
  334. .. rst-class:: classref-item-separator
  335. ----
  336. .. _class_NavigationServer2D_method_link_set_enter_cost:
  337. .. rst-class:: classref-method
  338. void **link_set_enter_cost** **(** :ref:`RID<class_RID>` link, :ref:`float<class_float>` enter_cost **)**
  339. Sets the ``enter_cost`` for this ``link``.
  340. .. rst-class:: classref-item-separator
  341. ----
  342. .. _class_NavigationServer2D_method_link_set_map:
  343. .. rst-class:: classref-method
  344. void **link_set_map** **(** :ref:`RID<class_RID>` link, :ref:`RID<class_RID>` map **)**
  345. Sets the navigation map :ref:`RID<class_RID>` for the link.
  346. .. rst-class:: classref-item-separator
  347. ----
  348. .. _class_NavigationServer2D_method_link_set_navigation_layers:
  349. .. rst-class:: classref-method
  350. void **link_set_navigation_layers** **(** :ref:`RID<class_RID>` link, :ref:`int<class_int>` navigation_layers **)**
  351. Set the links's navigation layers. This allows selecting links from a path request (when using :ref:`map_get_path<class_NavigationServer2D_method_map_get_path>`).
  352. .. rst-class:: classref-item-separator
  353. ----
  354. .. _class_NavigationServer2D_method_link_set_owner_id:
  355. .. rst-class:: classref-method
  356. void **link_set_owner_id** **(** :ref:`RID<class_RID>` link, :ref:`int<class_int>` owner_id **)**
  357. Set the ``ObjectID`` of the object which manages this link.
  358. .. rst-class:: classref-item-separator
  359. ----
  360. .. _class_NavigationServer2D_method_link_set_start_position:
  361. .. rst-class:: classref-method
  362. void **link_set_start_position** **(** :ref:`RID<class_RID>` link, :ref:`Vector2<class_Vector2>` position **)**
  363. Sets the entry position for this ``link``.
  364. .. rst-class:: classref-item-separator
  365. ----
  366. .. _class_NavigationServer2D_method_link_set_travel_cost:
  367. .. rst-class:: classref-method
  368. void **link_set_travel_cost** **(** :ref:`RID<class_RID>` link, :ref:`float<class_float>` travel_cost **)**
  369. Sets the ``travel_cost`` for this ``link``.
  370. .. rst-class:: classref-item-separator
  371. ----
  372. .. _class_NavigationServer2D_method_map_create:
  373. .. rst-class:: classref-method
  374. :ref:`RID<class_RID>` **map_create** **(** **)**
  375. Create a new map.
  376. .. rst-class:: classref-item-separator
  377. ----
  378. .. _class_NavigationServer2D_method_map_force_update:
  379. .. rst-class:: classref-method
  380. void **map_force_update** **(** :ref:`RID<class_RID>` map **)**
  381. This function immediately forces synchronization of the specified navigation ``map`` :ref:`RID<class_RID>`. By default navigation maps are only synchronized at the end of each physics frame. This function can be used to immediately (re)calculate all the navigation meshes and region connections of the navigation map. This makes it possible to query a navigation path for a changed map immediately and in the same frame (multiple times if needed).
  382. Due to technical restrictions the current NavigationServer command queue will be flushed. This means all already queued update commands for this physics frame will be executed, even those intended for other maps, regions and agents not part of the specified map. The expensive computation of the navigation meshes and region connections of a map will only be done for the specified map. Other maps will receive the normal synchronization at the end of the physics frame. Should the specified map receive changes after the forced update it will update again as well when the other maps receive their update.
  383. Avoidance processing and dispatch of the ``safe_velocity`` signals is untouched by this function and continues to happen for all maps and agents at the end of the physics frame.
  384. \ **Note:** With great power comes great responsibility. This function should only be used by users that really know what they are doing and have a good reason for it. Forcing an immediate update of a navigation map requires locking the NavigationServer and flushing the entire NavigationServer command queue. Not only can this severely impact the performance of a game but it can also introduce bugs if used inappropriately without much foresight.
  385. .. rst-class:: classref-item-separator
  386. ----
  387. .. _class_NavigationServer2D_method_map_get_agents:
  388. .. rst-class:: classref-method
  389. :ref:`RID[]<class_RID>` **map_get_agents** **(** :ref:`RID<class_RID>` map **)** |const|
  390. Returns all navigation agents :ref:`RID<class_RID>`\ s that are currently assigned to the requested navigation ``map``.
  391. .. rst-class:: classref-item-separator
  392. ----
  393. .. _class_NavigationServer2D_method_map_get_cell_size:
  394. .. rst-class:: classref-method
  395. :ref:`float<class_float>` **map_get_cell_size** **(** :ref:`RID<class_RID>` map **)** |const|
  396. Returns the map cell size.
  397. .. rst-class:: classref-item-separator
  398. ----
  399. .. _class_NavigationServer2D_method_map_get_closest_point:
  400. .. rst-class:: classref-method
  401. :ref:`Vector2<class_Vector2>` **map_get_closest_point** **(** :ref:`RID<class_RID>` map, :ref:`Vector2<class_Vector2>` to_point **)** |const|
  402. Returns the point closest to the provided ``to_point`` on the navigation mesh surface.
  403. .. rst-class:: classref-item-separator
  404. ----
  405. .. _class_NavigationServer2D_method_map_get_closest_point_owner:
  406. .. rst-class:: classref-method
  407. :ref:`RID<class_RID>` **map_get_closest_point_owner** **(** :ref:`RID<class_RID>` map, :ref:`Vector2<class_Vector2>` to_point **)** |const|
  408. Returns the owner region RID for the point returned by :ref:`map_get_closest_point<class_NavigationServer2D_method_map_get_closest_point>`.
  409. .. rst-class:: classref-item-separator
  410. ----
  411. .. _class_NavigationServer2D_method_map_get_edge_connection_margin:
  412. .. rst-class:: classref-method
  413. :ref:`float<class_float>` **map_get_edge_connection_margin** **(** :ref:`RID<class_RID>` map **)** |const|
  414. Returns the edge connection margin of the map. The edge connection margin is a distance used to connect two regions.
  415. .. rst-class:: classref-item-separator
  416. ----
  417. .. _class_NavigationServer2D_method_map_get_link_connection_radius:
  418. .. rst-class:: classref-method
  419. :ref:`float<class_float>` **map_get_link_connection_radius** **(** :ref:`RID<class_RID>` map **)** |const|
  420. Returns the link connection radius of the map. This distance is the maximum range any link will search for navigation mesh polygons to connect to.
  421. .. rst-class:: classref-item-separator
  422. ----
  423. .. _class_NavigationServer2D_method_map_get_links:
  424. .. rst-class:: classref-method
  425. :ref:`RID[]<class_RID>` **map_get_links** **(** :ref:`RID<class_RID>` map **)** |const|
  426. Returns all navigation link :ref:`RID<class_RID>`\ s that are currently assigned to the requested navigation ``map``.
  427. .. rst-class:: classref-item-separator
  428. ----
  429. .. _class_NavigationServer2D_method_map_get_path:
  430. .. rst-class:: classref-method
  431. :ref:`PackedVector2Array<class_PackedVector2Array>` **map_get_path** **(** :ref:`RID<class_RID>` map, :ref:`Vector2<class_Vector2>` origin, :ref:`Vector2<class_Vector2>` destination, :ref:`bool<class_bool>` optimize, :ref:`int<class_int>` navigation_layers=1 **)** |const|
  432. Returns the navigation path to reach the destination from the origin. ``navigation_layers`` is a bitmask of all region navigation layers that are allowed to be in the path.
  433. .. rst-class:: classref-item-separator
  434. ----
  435. .. _class_NavigationServer2D_method_map_get_regions:
  436. .. rst-class:: classref-method
  437. :ref:`RID[]<class_RID>` **map_get_regions** **(** :ref:`RID<class_RID>` map **)** |const|
  438. Returns all navigation regions :ref:`RID<class_RID>`\ s that are currently assigned to the requested navigation ``map``.
  439. .. rst-class:: classref-item-separator
  440. ----
  441. .. _class_NavigationServer2D_method_map_is_active:
  442. .. rst-class:: classref-method
  443. :ref:`bool<class_bool>` **map_is_active** **(** :ref:`RID<class_RID>` map **)** |const|
  444. Returns true if the map is active.
  445. .. rst-class:: classref-item-separator
  446. ----
  447. .. _class_NavigationServer2D_method_map_set_active:
  448. .. rst-class:: classref-method
  449. void **map_set_active** **(** :ref:`RID<class_RID>` map, :ref:`bool<class_bool>` active **)**
  450. Sets the map active.
  451. .. rst-class:: classref-item-separator
  452. ----
  453. .. _class_NavigationServer2D_method_map_set_cell_size:
  454. .. rst-class:: classref-method
  455. void **map_set_cell_size** **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` cell_size **)**
  456. Set the map cell size used to weld the navigation mesh polygons.
  457. .. rst-class:: classref-item-separator
  458. ----
  459. .. _class_NavigationServer2D_method_map_set_edge_connection_margin:
  460. .. rst-class:: classref-method
  461. void **map_set_edge_connection_margin** **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` margin **)**
  462. Set the map edge connection margin used to weld the compatible region edges.
  463. .. rst-class:: classref-item-separator
  464. ----
  465. .. _class_NavigationServer2D_method_map_set_link_connection_radius:
  466. .. rst-class:: classref-method
  467. void **map_set_link_connection_radius** **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` radius **)**
  468. Set the map's link connection radius used to connect links to navigation polygons.
  469. .. rst-class:: classref-item-separator
  470. ----
  471. .. _class_NavigationServer2D_method_query_path:
  472. .. rst-class:: classref-method
  473. void **query_path** **(** :ref:`NavigationPathQueryParameters2D<class_NavigationPathQueryParameters2D>` parameters, :ref:`NavigationPathQueryResult2D<class_NavigationPathQueryResult2D>` result **)** |const|
  474. Queries a path in a given navigation map. Start and target position and other parameters are defined through :ref:`NavigationPathQueryParameters2D<class_NavigationPathQueryParameters2D>`. Updates the provided :ref:`NavigationPathQueryResult2D<class_NavigationPathQueryResult2D>` result object with the path among other results requested by the query.
  475. .. rst-class:: classref-item-separator
  476. ----
  477. .. _class_NavigationServer2D_method_region_create:
  478. .. rst-class:: classref-method
  479. :ref:`RID<class_RID>` **region_create** **(** **)**
  480. Creates a new region.
  481. .. rst-class:: classref-item-separator
  482. ----
  483. .. _class_NavigationServer2D_method_region_get_connection_pathway_end:
  484. .. rst-class:: classref-method
  485. :ref:`Vector2<class_Vector2>` **region_get_connection_pathway_end** **(** :ref:`RID<class_RID>` region, :ref:`int<class_int>` connection **)** |const|
  486. Returns the ending point of a connection door. ``connection`` is an index between 0 and the return value of :ref:`region_get_connections_count<class_NavigationServer2D_method_region_get_connections_count>`.
  487. .. rst-class:: classref-item-separator
  488. ----
  489. .. _class_NavigationServer2D_method_region_get_connection_pathway_start:
  490. .. rst-class:: classref-method
  491. :ref:`Vector2<class_Vector2>` **region_get_connection_pathway_start** **(** :ref:`RID<class_RID>` region, :ref:`int<class_int>` connection **)** |const|
  492. Returns the starting point of a connection door. ``connection`` is an index between 0 and the return value of :ref:`region_get_connections_count<class_NavigationServer2D_method_region_get_connections_count>`.
  493. .. rst-class:: classref-item-separator
  494. ----
  495. .. _class_NavigationServer2D_method_region_get_connections_count:
  496. .. rst-class:: classref-method
  497. :ref:`int<class_int>` **region_get_connections_count** **(** :ref:`RID<class_RID>` region **)** |const|
  498. Returns how many connections this ``region`` has with other regions in the map.
  499. .. rst-class:: classref-item-separator
  500. ----
  501. .. _class_NavigationServer2D_method_region_get_enter_cost:
  502. .. rst-class:: classref-method
  503. :ref:`float<class_float>` **region_get_enter_cost** **(** :ref:`RID<class_RID>` region **)** |const|
  504. Returns the ``enter_cost`` of this ``region``.
  505. .. rst-class:: classref-item-separator
  506. ----
  507. .. _class_NavigationServer2D_method_region_get_map:
  508. .. rst-class:: classref-method
  509. :ref:`RID<class_RID>` **region_get_map** **(** :ref:`RID<class_RID>` region **)** |const|
  510. Returns the navigation map :ref:`RID<class_RID>` the requested ``region`` is currently assigned to.
  511. .. rst-class:: classref-item-separator
  512. ----
  513. .. _class_NavigationServer2D_method_region_get_navigation_layers:
  514. .. rst-class:: classref-method
  515. :ref:`int<class_int>` **region_get_navigation_layers** **(** :ref:`RID<class_RID>` region **)** |const|
  516. Returns the region's navigation layers.
  517. .. rst-class:: classref-item-separator
  518. ----
  519. .. _class_NavigationServer2D_method_region_get_owner_id:
  520. .. rst-class:: classref-method
  521. :ref:`int<class_int>` **region_get_owner_id** **(** :ref:`RID<class_RID>` region **)** |const|
  522. Returns the ``ObjectID`` of the object which manages this region.
  523. .. rst-class:: classref-item-separator
  524. ----
  525. .. _class_NavigationServer2D_method_region_get_travel_cost:
  526. .. rst-class:: classref-method
  527. :ref:`float<class_float>` **region_get_travel_cost** **(** :ref:`RID<class_RID>` region **)** |const|
  528. Returns the ``travel_cost`` of this ``region``.
  529. .. rst-class:: classref-item-separator
  530. ----
  531. .. _class_NavigationServer2D_method_region_owns_point:
  532. .. rst-class:: classref-method
  533. :ref:`bool<class_bool>` **region_owns_point** **(** :ref:`RID<class_RID>` region, :ref:`Vector2<class_Vector2>` point **)** |const|
  534. Returns ``true`` if the provided ``point`` in world space is currently owned by the provided navigation ``region``. Owned in this context means that one of the region's navigation mesh polygon faces has a possible position at the closest distance to this point compared to all other navigation meshes from other navigation regions that are also registered on the navigation map of the provided region.
  535. If multiple navigation meshes have positions at equal distance the navigation region whose polygons are processed first wins the ownership. Polygons are processed in the same order that navigation regions were registered on the NavigationServer.
  536. \ **Note:** If navigation meshes from different navigation regions overlap (which should be avoided in general) the result might not be what is expected.
  537. .. rst-class:: classref-item-separator
  538. ----
  539. .. _class_NavigationServer2D_method_region_set_enter_cost:
  540. .. rst-class:: classref-method
  541. void **region_set_enter_cost** **(** :ref:`RID<class_RID>` region, :ref:`float<class_float>` enter_cost **)**
  542. Sets the ``enter_cost`` for this ``region``.
  543. .. rst-class:: classref-item-separator
  544. ----
  545. .. _class_NavigationServer2D_method_region_set_map:
  546. .. rst-class:: classref-method
  547. void **region_set_map** **(** :ref:`RID<class_RID>` region, :ref:`RID<class_RID>` map **)**
  548. Sets the map for the region.
  549. .. rst-class:: classref-item-separator
  550. ----
  551. .. _class_NavigationServer2D_method_region_set_navigation_layers:
  552. .. rst-class:: classref-method
  553. void **region_set_navigation_layers** **(** :ref:`RID<class_RID>` region, :ref:`int<class_int>` navigation_layers **)**
  554. Set the region's navigation layers. This allows selecting regions from a path request (when using :ref:`map_get_path<class_NavigationServer2D_method_map_get_path>`).
  555. .. rst-class:: classref-item-separator
  556. ----
  557. .. _class_NavigationServer2D_method_region_set_navigation_polygon:
  558. .. rst-class:: classref-method
  559. void **region_set_navigation_polygon** **(** :ref:`RID<class_RID>` region, :ref:`NavigationPolygon<class_NavigationPolygon>` navigation_polygon **)**
  560. Sets the ``navigation_polygon`` for the region.
  561. .. rst-class:: classref-item-separator
  562. ----
  563. .. _class_NavigationServer2D_method_region_set_owner_id:
  564. .. rst-class:: classref-method
  565. void **region_set_owner_id** **(** :ref:`RID<class_RID>` region, :ref:`int<class_int>` owner_id **)**
  566. Set the ``ObjectID`` of the object which manages this region.
  567. .. rst-class:: classref-item-separator
  568. ----
  569. .. _class_NavigationServer2D_method_region_set_transform:
  570. .. rst-class:: classref-method
  571. void **region_set_transform** **(** :ref:`RID<class_RID>` region, :ref:`Transform2D<class_Transform2D>` transform **)**
  572. Sets the global transformation for the region.
  573. .. rst-class:: classref-item-separator
  574. ----
  575. .. _class_NavigationServer2D_method_region_set_travel_cost:
  576. .. rst-class:: classref-method
  577. void **region_set_travel_cost** **(** :ref:`RID<class_RID>` region, :ref:`float<class_float>` travel_cost **)**
  578. Sets the ``travel_cost`` for this ``region``.
  579. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  580. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  581. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  582. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  583. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  584. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`