class_navigationserver.rst 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.5/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.5/doc/classes/NavigationServer.xml.
  6. .. _class_NavigationServer:
  7. NavigationServer
  8. ================
  9. **Inherits:** :ref:`Object<class_Object>`
  10. Server interface for low-level 3D navigation access.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. NavigationServer is the server responsible for all 3D navigation. It handles several objects, namely maps, regions and agents.
  15. Maps are made up of regions, which are made of navigation meshes. Together, they define the navigable areas in the 3D 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 :ref:`Navigation.edge_connection_margin<class_Navigation_property_edge_connection_margin>` to the respective other edge's vertex.
  18. 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.
  19. \ **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.
  20. \ **Note:** By default, the expensive calculations for avoidance are done in a thread. In HTML5 exports without thread support, they will be done on the main thread, which can lead to performance issues.
  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. - `3D Navmesh Demo <https://godotengine.org/asset-library/asset/124>`__
  26. .. rst-class:: classref-reftable-group
  27. Methods
  28. -------
  29. .. table::
  30. :widths: auto
  31. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`RID<class_RID>` | :ref:`agent_create<class_NavigationServer_method_agent_create>` **(** **)** |const| |
  33. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`RID<class_RID>` | :ref:`agent_get_map<class_NavigationServer_method_agent_get_map>` **(** :ref:`RID<class_RID>` agent **)** |const| |
  35. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`bool<class_bool>` | :ref:`agent_is_map_changed<class_NavigationServer_method_agent_is_map_changed>` **(** :ref:`RID<class_RID>` agent **)** |const| |
  37. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`agent_set_callback<class_NavigationServer_method_agent_set_callback>` **(** :ref:`RID<class_RID>` agent, :ref:`Object<class_Object>` receiver, :ref:`String<class_String>` method, :ref:`Variant<class_Variant>` userdata=null **)** |const| |
  39. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`agent_set_map<class_NavigationServer_method_agent_set_map>` **(** :ref:`RID<class_RID>` agent, :ref:`RID<class_RID>` map **)** |const| |
  41. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`agent_set_max_neighbors<class_NavigationServer_method_agent_set_max_neighbors>` **(** :ref:`RID<class_RID>` agent, :ref:`int<class_int>` count **)** |const| |
  43. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`agent_set_max_speed<class_NavigationServer_method_agent_set_max_speed>` **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` max_speed **)** |const| |
  45. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`agent_set_neighbor_dist<class_NavigationServer_method_agent_set_neighbor_dist>` **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` dist **)** |const| |
  47. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | void | :ref:`agent_set_position<class_NavigationServer_method_agent_set_position>` **(** :ref:`RID<class_RID>` agent, :ref:`Vector3<class_Vector3>` position **)** |const| |
  49. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`agent_set_radius<class_NavigationServer_method_agent_set_radius>` **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` radius **)** |const| |
  51. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`agent_set_target_velocity<class_NavigationServer_method_agent_set_target_velocity>` **(** :ref:`RID<class_RID>` agent, :ref:`Vector3<class_Vector3>` target_velocity **)** |const| |
  53. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`agent_set_time_horizon<class_NavigationServer_method_agent_set_time_horizon>` **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` time **)** |const| |
  55. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`agent_set_velocity<class_NavigationServer_method_agent_set_velocity>` **(** :ref:`RID<class_RID>` agent, :ref:`Vector3<class_Vector3>` velocity **)** |const| |
  57. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`free_rid<class_NavigationServer_method_free_rid>` **(** :ref:`RID<class_RID>` rid **)** |const| |
  59. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`Array<class_Array>` | :ref:`get_maps<class_NavigationServer_method_get_maps>` **(** **)** |const| |
  61. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`RID<class_RID>` | :ref:`map_create<class_NavigationServer_method_map_create>` **(** **)** |const| |
  63. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | void | :ref:`map_force_update<class_NavigationServer_method_map_force_update>` **(** :ref:`RID<class_RID>` map **)** |
  65. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`Array<class_Array>` | :ref:`map_get_agents<class_NavigationServer_method_map_get_agents>` **(** :ref:`RID<class_RID>` map **)** |const| |
  67. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`float<class_float>` | :ref:`map_get_cell_height<class_NavigationServer_method_map_get_cell_height>` **(** :ref:`RID<class_RID>` map **)** |const| |
  69. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`float<class_float>` | :ref:`map_get_cell_size<class_NavigationServer_method_map_get_cell_size>` **(** :ref:`RID<class_RID>` map **)** |const| |
  71. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`Vector3<class_Vector3>` | :ref:`map_get_closest_point<class_NavigationServer_method_map_get_closest_point>` **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` to_point **)** |const| |
  73. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`Vector3<class_Vector3>` | :ref:`map_get_closest_point_normal<class_NavigationServer_method_map_get_closest_point_normal>` **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` to_point **)** |const| |
  75. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`RID<class_RID>` | :ref:`map_get_closest_point_owner<class_NavigationServer_method_map_get_closest_point_owner>` **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` to_point **)** |const| |
  77. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`Vector3<class_Vector3>` | :ref:`map_get_closest_point_to_segment<class_NavigationServer_method_map_get_closest_point_to_segment>` **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` start, :ref:`Vector3<class_Vector3>` end, :ref:`bool<class_bool>` use_collision=false **)** |const| |
  79. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | :ref:`float<class_float>` | :ref:`map_get_edge_connection_margin<class_NavigationServer_method_map_get_edge_connection_margin>` **(** :ref:`RID<class_RID>` map **)** |const| |
  81. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | :ref:`PoolVector3Array<class_PoolVector3Array>` | :ref:`map_get_path<class_NavigationServer_method_map_get_path>` **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` origin, :ref:`Vector3<class_Vector3>` destination, :ref:`bool<class_bool>` optimize, :ref:`int<class_int>` navigation_layers=1 **)** |const| |
  83. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | :ref:`Array<class_Array>` | :ref:`map_get_regions<class_NavigationServer_method_map_get_regions>` **(** :ref:`RID<class_RID>` map **)** |const| |
  85. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | :ref:`Vector3<class_Vector3>` | :ref:`map_get_up<class_NavigationServer_method_map_get_up>` **(** :ref:`RID<class_RID>` map **)** |const| |
  87. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | :ref:`bool<class_bool>` | :ref:`map_is_active<class_NavigationServer_method_map_is_active>` **(** :ref:`RID<class_RID>` map **)** |const| |
  89. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | void | :ref:`map_set_active<class_NavigationServer_method_map_set_active>` **(** :ref:`RID<class_RID>` map, :ref:`bool<class_bool>` active **)** |const| |
  91. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | void | :ref:`map_set_cell_height<class_NavigationServer_method_map_set_cell_height>` **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` cell_height **)** |const| |
  93. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | void | :ref:`map_set_cell_size<class_NavigationServer_method_map_set_cell_size>` **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` cell_size **)** |const| |
  95. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | void | :ref:`map_set_edge_connection_margin<class_NavigationServer_method_map_set_edge_connection_margin>` **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` margin **)** |const| |
  97. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | void | :ref:`map_set_up<class_NavigationServer_method_map_set_up>` **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` up **)** |const| |
  99. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | void | :ref:`process<class_NavigationServer_method_process>` **(** :ref:`float<class_float>` delta_time **)** |
  101. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | void | :ref:`region_bake_navmesh<class_NavigationServer_method_region_bake_navmesh>` **(** :ref:`NavigationMesh<class_NavigationMesh>` mesh, :ref:`Node<class_Node>` node **)** |const| |
  103. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`RID<class_RID>` | :ref:`region_create<class_NavigationServer_method_region_create>` **(** **)** |const| |
  105. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`Vector3<class_Vector3>` | :ref:`region_get_connection_pathway_end<class_NavigationServer_method_region_get_connection_pathway_end>` **(** :ref:`RID<class_RID>` region, :ref:`int<class_int>` connection **)** |const| |
  107. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`Vector3<class_Vector3>` | :ref:`region_get_connection_pathway_start<class_NavigationServer_method_region_get_connection_pathway_start>` **(** :ref:`RID<class_RID>` region, :ref:`int<class_int>` connection **)** |const| |
  109. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`int<class_int>` | :ref:`region_get_connections_count<class_NavigationServer_method_region_get_connections_count>` **(** :ref:`RID<class_RID>` region **)** |const| |
  111. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`float<class_float>` | :ref:`region_get_enter_cost<class_NavigationServer_method_region_get_enter_cost>` **(** :ref:`RID<class_RID>` region **)** |const| |
  113. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`RID<class_RID>` | :ref:`region_get_map<class_NavigationServer_method_region_get_map>` **(** :ref:`RID<class_RID>` region **)** |const| |
  115. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | :ref:`int<class_int>` | :ref:`region_get_navigation_layers<class_NavigationServer_method_region_get_navigation_layers>` **(** :ref:`RID<class_RID>` region **)** |const| |
  117. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`float<class_float>` | :ref:`region_get_travel_cost<class_NavigationServer_method_region_get_travel_cost>` **(** :ref:`RID<class_RID>` region **)** |const| |
  119. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`bool<class_bool>` | :ref:`region_owns_point<class_NavigationServer_method_region_owns_point>` **(** :ref:`RID<class_RID>` region, :ref:`Vector3<class_Vector3>` point **)** |const| |
  121. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | void | :ref:`region_set_enter_cost<class_NavigationServer_method_region_set_enter_cost>` **(** :ref:`RID<class_RID>` region, :ref:`float<class_float>` enter_cost **)** |const| |
  123. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | void | :ref:`region_set_map<class_NavigationServer_method_region_set_map>` **(** :ref:`RID<class_RID>` region, :ref:`RID<class_RID>` map **)** |const| |
  125. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | void | :ref:`region_set_navigation_layers<class_NavigationServer_method_region_set_navigation_layers>` **(** :ref:`RID<class_RID>` region, :ref:`int<class_int>` navigation_layers **)** |const| |
  127. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | void | :ref:`region_set_navmesh<class_NavigationServer_method_region_set_navmesh>` **(** :ref:`RID<class_RID>` region, :ref:`NavigationMesh<class_NavigationMesh>` nav_mesh **)** |const| |
  129. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | void | :ref:`region_set_transform<class_NavigationServer_method_region_set_transform>` **(** :ref:`RID<class_RID>` region, :ref:`Transform<class_Transform>` transform **)** |const| |
  131. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | void | :ref:`region_set_travel_cost<class_NavigationServer_method_region_set_travel_cost>` **(** :ref:`RID<class_RID>` region, :ref:`float<class_float>` travel_cost **)** |const| |
  133. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | void | :ref:`set_active<class_NavigationServer_method_set_active>` **(** :ref:`bool<class_bool>` active **)** |const| |
  135. +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. .. rst-class:: classref-section-separator
  137. ----
  138. .. rst-class:: classref-descriptions-group
  139. Signals
  140. -------
  141. .. _class_NavigationServer_signal_map_changed:
  142. .. rst-class:: classref-signal
  143. **map_changed** **(** :ref:`RID<class_RID>` map **)**
  144. Emitted when a navigation map is updated, when a region moves or is modified.
  145. .. rst-class:: classref-section-separator
  146. ----
  147. .. rst-class:: classref-descriptions-group
  148. Method Descriptions
  149. -------------------
  150. .. _class_NavigationServer_method_agent_create:
  151. .. rst-class:: classref-method
  152. :ref:`RID<class_RID>` **agent_create** **(** **)** |const|
  153. Creates the agent.
  154. .. rst-class:: classref-item-separator
  155. ----
  156. .. _class_NavigationServer_method_agent_get_map:
  157. .. rst-class:: classref-method
  158. :ref:`RID<class_RID>` **agent_get_map** **(** :ref:`RID<class_RID>` agent **)** |const|
  159. Returns the navigation map :ref:`RID<class_RID>` the requested ``agent`` is currently assigned to.
  160. .. rst-class:: classref-item-separator
  161. ----
  162. .. _class_NavigationServer_method_agent_is_map_changed:
  163. .. rst-class:: classref-method
  164. :ref:`bool<class_bool>` **agent_is_map_changed** **(** :ref:`RID<class_RID>` agent **)** |const|
  165. Returns ``true`` if the map got changed the previous frame.
  166. .. rst-class:: classref-item-separator
  167. ----
  168. .. _class_NavigationServer_method_agent_set_callback:
  169. .. rst-class:: classref-method
  170. void **agent_set_callback** **(** :ref:`RID<class_RID>` agent, :ref:`Object<class_Object>` receiver, :ref:`String<class_String>` method, :ref:`Variant<class_Variant>` userdata=null **)** |const|
  171. Callback called at the end of the RVO process. If a callback is created manually and the agent is placed on a navigation map it will calculate avoidance for the agent and dispatch the calculated ``safe_velocity`` to the ``receiver`` object with a signal to the chosen ``method`` name.
  172. \ **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_NavigationServer_method_agent_set_callback>` again with a ``null`` object as the ``receiver``.
  173. .. rst-class:: classref-item-separator
  174. ----
  175. .. _class_NavigationServer_method_agent_set_map:
  176. .. rst-class:: classref-method
  177. void **agent_set_map** **(** :ref:`RID<class_RID>` agent, :ref:`RID<class_RID>` map **)** |const|
  178. Puts the agent in the map.
  179. .. rst-class:: classref-item-separator
  180. ----
  181. .. _class_NavigationServer_method_agent_set_max_neighbors:
  182. .. rst-class:: classref-method
  183. void **agent_set_max_neighbors** **(** :ref:`RID<class_RID>` agent, :ref:`int<class_int>` count **)** |const|
  184. 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.
  185. .. rst-class:: classref-item-separator
  186. ----
  187. .. _class_NavigationServer_method_agent_set_max_speed:
  188. .. rst-class:: classref-method
  189. void **agent_set_max_speed** **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` max_speed **)** |const|
  190. Sets the maximum speed of the agent. Must be positive.
  191. .. rst-class:: classref-item-separator
  192. ----
  193. .. _class_NavigationServer_method_agent_set_neighbor_dist:
  194. .. rst-class:: classref-method
  195. void **agent_set_neighbor_dist** **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` dist **)** |const|
  196. 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.
  197. .. rst-class:: classref-item-separator
  198. ----
  199. .. _class_NavigationServer_method_agent_set_position:
  200. .. rst-class:: classref-method
  201. void **agent_set_position** **(** :ref:`RID<class_RID>` agent, :ref:`Vector3<class_Vector3>` position **)** |const|
  202. Sets the position of the agent in world space.
  203. .. rst-class:: classref-item-separator
  204. ----
  205. .. _class_NavigationServer_method_agent_set_radius:
  206. .. rst-class:: classref-method
  207. void **agent_set_radius** **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` radius **)** |const|
  208. Sets the radius of the agent.
  209. .. rst-class:: classref-item-separator
  210. ----
  211. .. _class_NavigationServer_method_agent_set_target_velocity:
  212. .. rst-class:: classref-method
  213. void **agent_set_target_velocity** **(** :ref:`RID<class_RID>` agent, :ref:`Vector3<class_Vector3>` target_velocity **)** |const|
  214. Sets the new target velocity.
  215. .. rst-class:: classref-item-separator
  216. ----
  217. .. _class_NavigationServer_method_agent_set_time_horizon:
  218. .. rst-class:: classref-method
  219. void **agent_set_time_horizon** **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` time **)** |const|
  220. 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.
  221. .. rst-class:: classref-item-separator
  222. ----
  223. .. _class_NavigationServer_method_agent_set_velocity:
  224. .. rst-class:: classref-method
  225. void **agent_set_velocity** **(** :ref:`RID<class_RID>` agent, :ref:`Vector3<class_Vector3>` velocity **)** |const|
  226. Sets the current velocity of the agent.
  227. .. rst-class:: classref-item-separator
  228. ----
  229. .. _class_NavigationServer_method_free_rid:
  230. .. rst-class:: classref-method
  231. void **free_rid** **(** :ref:`RID<class_RID>` rid **)** |const|
  232. Destroys the given RID.
  233. .. rst-class:: classref-item-separator
  234. ----
  235. .. _class_NavigationServer_method_get_maps:
  236. .. rst-class:: classref-method
  237. :ref:`Array<class_Array>` **get_maps** **(** **)** |const|
  238. 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.
  239. .. rst-class:: classref-item-separator
  240. ----
  241. .. _class_NavigationServer_method_map_create:
  242. .. rst-class:: classref-method
  243. :ref:`RID<class_RID>` **map_create** **(** **)** |const|
  244. Create a new map.
  245. .. rst-class:: classref-item-separator
  246. ----
  247. .. _class_NavigationServer_method_map_force_update:
  248. .. rst-class:: classref-method
  249. void **map_force_update** **(** :ref:`RID<class_RID>` map **)**
  250. 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).
  251. 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.
  252. 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.
  253. \ **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.
  254. .. rst-class:: classref-item-separator
  255. ----
  256. .. _class_NavigationServer_method_map_get_agents:
  257. .. rst-class:: classref-method
  258. :ref:`Array<class_Array>` **map_get_agents** **(** :ref:`RID<class_RID>` map **)** |const|
  259. Returns all navigation agents :ref:`RID<class_RID>`\ s that are currently assigned to the requested navigation ``map``.
  260. .. rst-class:: classref-item-separator
  261. ----
  262. .. _class_NavigationServer_method_map_get_cell_height:
  263. .. rst-class:: classref-method
  264. :ref:`float<class_float>` **map_get_cell_height** **(** :ref:`RID<class_RID>` map **)** |const|
  265. Returns the map cell height.
  266. .. rst-class:: classref-item-separator
  267. ----
  268. .. _class_NavigationServer_method_map_get_cell_size:
  269. .. rst-class:: classref-method
  270. :ref:`float<class_float>` **map_get_cell_size** **(** :ref:`RID<class_RID>` map **)** |const|
  271. Returns the map cell size.
  272. .. rst-class:: classref-item-separator
  273. ----
  274. .. _class_NavigationServer_method_map_get_closest_point:
  275. .. rst-class:: classref-method
  276. :ref:`Vector3<class_Vector3>` **map_get_closest_point** **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` to_point **)** |const|
  277. Returns the point closest to the provided ``to_point`` on the navigation mesh surface.
  278. .. rst-class:: classref-item-separator
  279. ----
  280. .. _class_NavigationServer_method_map_get_closest_point_normal:
  281. .. rst-class:: classref-method
  282. :ref:`Vector3<class_Vector3>` **map_get_closest_point_normal** **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` to_point **)** |const|
  283. Returns the normal for the point returned by :ref:`map_get_closest_point<class_NavigationServer_method_map_get_closest_point>`.
  284. .. rst-class:: classref-item-separator
  285. ----
  286. .. _class_NavigationServer_method_map_get_closest_point_owner:
  287. .. rst-class:: classref-method
  288. :ref:`RID<class_RID>` **map_get_closest_point_owner** **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` to_point **)** |const|
  289. Returns the owner region RID for the point returned by :ref:`map_get_closest_point<class_NavigationServer_method_map_get_closest_point>`.
  290. .. rst-class:: classref-item-separator
  291. ----
  292. .. _class_NavigationServer_method_map_get_closest_point_to_segment:
  293. .. rst-class:: classref-method
  294. :ref:`Vector3<class_Vector3>` **map_get_closest_point_to_segment** **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` start, :ref:`Vector3<class_Vector3>` end, :ref:`bool<class_bool>` use_collision=false **)** |const|
  295. Returns the closest point between the navigation surface and the segment.
  296. .. rst-class:: classref-item-separator
  297. ----
  298. .. _class_NavigationServer_method_map_get_edge_connection_margin:
  299. .. rst-class:: classref-method
  300. :ref:`float<class_float>` **map_get_edge_connection_margin** **(** :ref:`RID<class_RID>` map **)** |const|
  301. Returns the edge connection margin of the map. This distance is the minimum vertex distance needed to connect two edges from different regions.
  302. .. rst-class:: classref-item-separator
  303. ----
  304. .. _class_NavigationServer_method_map_get_path:
  305. .. rst-class:: classref-method
  306. :ref:`PoolVector3Array<class_PoolVector3Array>` **map_get_path** **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` origin, :ref:`Vector3<class_Vector3>` destination, :ref:`bool<class_bool>` optimize, :ref:`int<class_int>` navigation_layers=1 **)** |const|
  307. Returns the navigation path to reach the destination from the origin. ``navigation_layers`` is a bitmask of all region layers that are allowed to be in the path.
  308. .. rst-class:: classref-item-separator
  309. ----
  310. .. _class_NavigationServer_method_map_get_regions:
  311. .. rst-class:: classref-method
  312. :ref:`Array<class_Array>` **map_get_regions** **(** :ref:`RID<class_RID>` map **)** |const|
  313. Returns all navigation regions :ref:`RID<class_RID>`\ s that are currently assigned to the requested navigation ``map``.
  314. .. rst-class:: classref-item-separator
  315. ----
  316. .. _class_NavigationServer_method_map_get_up:
  317. .. rst-class:: classref-method
  318. :ref:`Vector3<class_Vector3>` **map_get_up** **(** :ref:`RID<class_RID>` map **)** |const|
  319. Returns the map's up direction.
  320. .. rst-class:: classref-item-separator
  321. ----
  322. .. _class_NavigationServer_method_map_is_active:
  323. .. rst-class:: classref-method
  324. :ref:`bool<class_bool>` **map_is_active** **(** :ref:`RID<class_RID>` map **)** |const|
  325. Returns ``true`` if the map is active.
  326. .. rst-class:: classref-item-separator
  327. ----
  328. .. _class_NavigationServer_method_map_set_active:
  329. .. rst-class:: classref-method
  330. void **map_set_active** **(** :ref:`RID<class_RID>` map, :ref:`bool<class_bool>` active **)** |const|
  331. Sets the map active.
  332. .. rst-class:: classref-item-separator
  333. ----
  334. .. _class_NavigationServer_method_map_set_cell_height:
  335. .. rst-class:: classref-method
  336. void **map_set_cell_height** **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` cell_height **)** |const|
  337. Set the map cell height used to weld the navigation mesh polygons.
  338. .. rst-class:: classref-item-separator
  339. ----
  340. .. _class_NavigationServer_method_map_set_cell_size:
  341. .. rst-class:: classref-method
  342. void **map_set_cell_size** **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` cell_size **)** |const|
  343. Set the map cell size used to weld the navigation mesh polygons.
  344. .. rst-class:: classref-item-separator
  345. ----
  346. .. _class_NavigationServer_method_map_set_edge_connection_margin:
  347. .. rst-class:: classref-method
  348. void **map_set_edge_connection_margin** **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` margin **)** |const|
  349. Set the map edge connection margin used to weld the compatible region edges.
  350. .. rst-class:: classref-item-separator
  351. ----
  352. .. _class_NavigationServer_method_map_set_up:
  353. .. rst-class:: classref-method
  354. void **map_set_up** **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` up **)** |const|
  355. Sets the map up direction.
  356. .. rst-class:: classref-item-separator
  357. ----
  358. .. _class_NavigationServer_method_process:
  359. .. rst-class:: classref-method
  360. void **process** **(** :ref:`float<class_float>` delta_time **)**
  361. Process the collision avoidance agents.
  362. The result of this process is needed by the physics server, so this must be called in the main thread.
  363. \ **Note:** This function is not thread safe.
  364. .. rst-class:: classref-item-separator
  365. ----
  366. .. _class_NavigationServer_method_region_bake_navmesh:
  367. .. rst-class:: classref-method
  368. void **region_bake_navmesh** **(** :ref:`NavigationMesh<class_NavigationMesh>` mesh, :ref:`Node<class_Node>` node **)** |const|
  369. Bakes the navigation mesh.
  370. .. rst-class:: classref-item-separator
  371. ----
  372. .. _class_NavigationServer_method_region_create:
  373. .. rst-class:: classref-method
  374. :ref:`RID<class_RID>` **region_create** **(** **)** |const|
  375. Creates a new region.
  376. .. rst-class:: classref-item-separator
  377. ----
  378. .. _class_NavigationServer_method_region_get_connection_pathway_end:
  379. .. rst-class:: classref-method
  380. :ref:`Vector3<class_Vector3>` **region_get_connection_pathway_end** **(** :ref:`RID<class_RID>` region, :ref:`int<class_int>` connection **)** |const|
  381. 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_NavigationServer_method_region_get_connections_count>`.
  382. .. rst-class:: classref-item-separator
  383. ----
  384. .. _class_NavigationServer_method_region_get_connection_pathway_start:
  385. .. rst-class:: classref-method
  386. :ref:`Vector3<class_Vector3>` **region_get_connection_pathway_start** **(** :ref:`RID<class_RID>` region, :ref:`int<class_int>` connection **)** |const|
  387. 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_NavigationServer_method_region_get_connections_count>`.
  388. .. rst-class:: classref-item-separator
  389. ----
  390. .. _class_NavigationServer_method_region_get_connections_count:
  391. .. rst-class:: classref-method
  392. :ref:`int<class_int>` **region_get_connections_count** **(** :ref:`RID<class_RID>` region **)** |const|
  393. Returns how many connections this ``region`` has with other regions in the map.
  394. .. rst-class:: classref-item-separator
  395. ----
  396. .. _class_NavigationServer_method_region_get_enter_cost:
  397. .. rst-class:: classref-method
  398. :ref:`float<class_float>` **region_get_enter_cost** **(** :ref:`RID<class_RID>` region **)** |const|
  399. Returns the ``enter_cost`` of this ``region``.
  400. .. rst-class:: classref-item-separator
  401. ----
  402. .. _class_NavigationServer_method_region_get_map:
  403. .. rst-class:: classref-method
  404. :ref:`RID<class_RID>` **region_get_map** **(** :ref:`RID<class_RID>` region **)** |const|
  405. Returns the navigation map :ref:`RID<class_RID>` the requested ``region`` is currently assigned to.
  406. .. rst-class:: classref-item-separator
  407. ----
  408. .. _class_NavigationServer_method_region_get_navigation_layers:
  409. .. rst-class:: classref-method
  410. :ref:`int<class_int>` **region_get_navigation_layers** **(** :ref:`RID<class_RID>` region **)** |const|
  411. Returns the region's navigation layers.
  412. .. rst-class:: classref-item-separator
  413. ----
  414. .. _class_NavigationServer_method_region_get_travel_cost:
  415. .. rst-class:: classref-method
  416. :ref:`float<class_float>` **region_get_travel_cost** **(** :ref:`RID<class_RID>` region **)** |const|
  417. Returns the ``travel_cost`` of this ``region``.
  418. .. rst-class:: classref-item-separator
  419. ----
  420. .. _class_NavigationServer_method_region_owns_point:
  421. .. rst-class:: classref-method
  422. :ref:`bool<class_bool>` **region_owns_point** **(** :ref:`RID<class_RID>` region, :ref:`Vector3<class_Vector3>` point **)** |const|
  423. 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.
  424. 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.
  425. \ **Note:** If navigation meshes from different navigation regions overlap (which should be avoided in general) the result might not be what is expected.
  426. .. rst-class:: classref-item-separator
  427. ----
  428. .. _class_NavigationServer_method_region_set_enter_cost:
  429. .. rst-class:: classref-method
  430. void **region_set_enter_cost** **(** :ref:`RID<class_RID>` region, :ref:`float<class_float>` enter_cost **)** |const|
  431. Sets the ``enter_cost`` for this ``region``.
  432. .. rst-class:: classref-item-separator
  433. ----
  434. .. _class_NavigationServer_method_region_set_map:
  435. .. rst-class:: classref-method
  436. void **region_set_map** **(** :ref:`RID<class_RID>` region, :ref:`RID<class_RID>` map **)** |const|
  437. Sets the map for the region.
  438. .. rst-class:: classref-item-separator
  439. ----
  440. .. _class_NavigationServer_method_region_set_navigation_layers:
  441. .. rst-class:: classref-method
  442. void **region_set_navigation_layers** **(** :ref:`RID<class_RID>` region, :ref:`int<class_int>` navigation_layers **)** |const|
  443. Set the region's navigation layers. This allows selecting regions from a path request (when using :ref:`map_get_path<class_NavigationServer_method_map_get_path>`).
  444. .. rst-class:: classref-item-separator
  445. ----
  446. .. _class_NavigationServer_method_region_set_navmesh:
  447. .. rst-class:: classref-method
  448. void **region_set_navmesh** **(** :ref:`RID<class_RID>` region, :ref:`NavigationMesh<class_NavigationMesh>` nav_mesh **)** |const|
  449. Sets the navigation mesh for the region.
  450. .. rst-class:: classref-item-separator
  451. ----
  452. .. _class_NavigationServer_method_region_set_transform:
  453. .. rst-class:: classref-method
  454. void **region_set_transform** **(** :ref:`RID<class_RID>` region, :ref:`Transform<class_Transform>` transform **)** |const|
  455. Sets the global transformation for the region.
  456. .. rst-class:: classref-item-separator
  457. ----
  458. .. _class_NavigationServer_method_region_set_travel_cost:
  459. .. rst-class:: classref-method
  460. void **region_set_travel_cost** **(** :ref:`RID<class_RID>` region, :ref:`float<class_float>` travel_cost **)** |const|
  461. Sets the ``travel_cost`` for this ``region``.
  462. .. rst-class:: classref-item-separator
  463. ----
  464. .. _class_NavigationServer_method_set_active:
  465. .. rst-class:: classref-method
  466. void **set_active** **(** :ref:`bool<class_bool>` active **)** |const|
  467. Control activation of this server.
  468. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  469. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  470. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  471. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`