class_navigationserver.rst 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the NavigationServer.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_NavigationServer:
  6. NavigationServer
  7. ================
  8. **Inherits:** :ref:`Object<class_Object>`
  9. Server interface for low-level 3D navigation access
  10. Description
  11. -----------
  12. NavigationServer is the server responsible for all 3D navigation. It creates the agents, maps, and regions for navigation to work as expected. This 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.
  13. Methods
  14. -------
  15. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`RID<class_RID>` | :ref:`agent_create<class_NavigationServer_method_agent_create>` **(** **)** const |
  17. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`bool<class_bool>` | :ref:`agent_is_map_changed<class_NavigationServer_method_agent_is_map_changed>` **(** :ref:`RID<class_RID>` agent **)** const |
  19. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`agent_set_callback<class_NavigationServer_method_agent_set_callback>` **(** :ref:`RID<class_RID>` agent, :ref:`Object<class_Object>` receiver, :ref:`StringName<class_StringName>` method, :ref:`Variant<class_Variant>` userdata=null **)** const |
  21. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`agent_set_map<class_NavigationServer_method_agent_set_map>` **(** :ref:`RID<class_RID>` agent, :ref:`RID<class_RID>` map **)** const |
  23. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`agent_set_max_neighbors<class_NavigationServer_method_agent_set_max_neighbors>` **(** :ref:`RID<class_RID>` agent, :ref:`int<class_int>` count **)** const |
  25. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | 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 |
  27. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`agent_set_neighbor_dist<class_NavigationServer_method_agent_set_neighbor_dist>` **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` dist **)** const |
  29. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`agent_set_position<class_NavigationServer_method_agent_set_position>` **(** :ref:`RID<class_RID>` agent, :ref:`Vector3<class_Vector3>` position **)** const |
  31. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`agent_set_radius<class_NavigationServer_method_agent_set_radius>` **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` radius **)** const |
  33. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | 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 |
  35. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`agent_set_time_horizon<class_NavigationServer_method_agent_set_time_horizon>` **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` time **)** const |
  37. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`agent_set_velocity<class_NavigationServer_method_agent_set_velocity>` **(** :ref:`RID<class_RID>` agent, :ref:`Vector3<class_Vector3>` velocity **)** const |
  39. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`free<class_NavigationServer_method_free>` **(** :ref:`RID<class_RID>` object **)** const |
  41. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`RID<class_RID>` | :ref:`map_create<class_NavigationServer_method_map_create>` **(** **)** const |
  43. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`float<class_float>` | :ref:`map_get_cell_size<class_NavigationServer_method_map_get_cell_size>` **(** :ref:`RID<class_RID>` map **)** const |
  45. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :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 |
  47. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :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 |
  49. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :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 |
  51. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :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 |
  53. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`float<class_float>` | :ref:`map_get_edge_connection_margin<class_NavigationServer_method_map_get_edge_connection_margin>` **(** :ref:`RID<class_RID>` map **)** const |
  55. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`PackedVector3Array<class_PackedVector3Array>` | :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 **)** const |
  57. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`Vector3<class_Vector3>` | :ref:`map_get_up<class_NavigationServer_method_map_get_up>` **(** :ref:`RID<class_RID>` map **)** const |
  59. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`bool<class_bool>` | :ref:`map_is_active<class_NavigationServer_method_map_is_active>` **(** :ref:`RID<class_RID>` nap **)** const |
  61. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`map_set_active<class_NavigationServer_method_map_set_active>` **(** :ref:`RID<class_RID>` map, :ref:`bool<class_bool>` active **)** const |
  63. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | 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 |
  65. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | 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 |
  67. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`map_set_up<class_NavigationServer_method_map_set_up>` **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` up **)** const |
  69. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | void | :ref:`process<class_NavigationServer_method_process>` **(** :ref:`float<class_float>` delta_time **)** |
  71. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | void | :ref:`region_bake_navmesh<class_NavigationServer_method_region_bake_navmesh>` **(** :ref:`NavigationMesh<class_NavigationMesh>` mesh, :ref:`Node<class_Node>` node **)** const |
  73. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`RID<class_RID>` | :ref:`region_create<class_NavigationServer_method_region_create>` **(** **)** const |
  75. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | void | :ref:`region_set_map<class_NavigationServer_method_region_set_map>` **(** :ref:`RID<class_RID>` region, :ref:`RID<class_RID>` map **)** const |
  77. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | void | :ref:`region_set_navmesh<class_NavigationServer_method_region_set_navmesh>` **(** :ref:`RID<class_RID>` region, :ref:`NavigationMesh<class_NavigationMesh>` nav_mesh **)** const |
  79. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | void | :ref:`region_set_transform<class_NavigationServer_method_region_set_transform>` **(** :ref:`RID<class_RID>` region, :ref:`Transform<class_Transform>` transform **)** const |
  81. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | void | :ref:`set_active<class_NavigationServer_method_set_active>` **(** :ref:`bool<class_bool>` active **)** const |
  83. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. Method Descriptions
  85. -------------------
  86. .. _class_NavigationServer_method_agent_create:
  87. - :ref:`RID<class_RID>` **agent_create** **(** **)** const
  88. Creates the agent.
  89. ----
  90. .. _class_NavigationServer_method_agent_is_map_changed:
  91. - :ref:`bool<class_bool>` **agent_is_map_changed** **(** :ref:`RID<class_RID>` agent **)** const
  92. Returns true if the map got changed the previous frame.
  93. ----
  94. .. _class_NavigationServer_method_agent_set_callback:
  95. - void **agent_set_callback** **(** :ref:`RID<class_RID>` agent, :ref:`Object<class_Object>` receiver, :ref:`StringName<class_StringName>` method, :ref:`Variant<class_Variant>` userdata=null **)** const
  96. Callback called at the end of the RVO process.
  97. ----
  98. .. _class_NavigationServer_method_agent_set_map:
  99. - void **agent_set_map** **(** :ref:`RID<class_RID>` agent, :ref:`RID<class_RID>` map **)** const
  100. Puts the agent in the map.
  101. ----
  102. .. _class_NavigationServer_method_agent_set_max_neighbors:
  103. - void **agent_set_max_neighbors** **(** :ref:`RID<class_RID>` agent, :ref:`int<class_int>` count **)** const
  104. 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.
  105. ----
  106. .. _class_NavigationServer_method_agent_set_max_speed:
  107. - void **agent_set_max_speed** **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` max_speed **)** const
  108. Sets the maximum speed of the agent. Must be positive.
  109. ----
  110. .. _class_NavigationServer_method_agent_set_neighbor_dist:
  111. - void **agent_set_neighbor_dist** **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` dist **)** const
  112. 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.
  113. ----
  114. .. _class_NavigationServer_method_agent_set_position:
  115. - void **agent_set_position** **(** :ref:`RID<class_RID>` agent, :ref:`Vector3<class_Vector3>` position **)** const
  116. Sets the position of the agent in world space.
  117. ----
  118. .. _class_NavigationServer_method_agent_set_radius:
  119. - void **agent_set_radius** **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` radius **)** const
  120. Sets the radius of the agent.
  121. ----
  122. .. _class_NavigationServer_method_agent_set_target_velocity:
  123. - void **agent_set_target_velocity** **(** :ref:`RID<class_RID>` agent, :ref:`Vector3<class_Vector3>` target_velocity **)** const
  124. Sets the new target velocity.
  125. ----
  126. .. _class_NavigationServer_method_agent_set_time_horizon:
  127. - void **agent_set_time_horizon** **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` time **)** const
  128. 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.
  129. ----
  130. .. _class_NavigationServer_method_agent_set_velocity:
  131. - void **agent_set_velocity** **(** :ref:`RID<class_RID>` agent, :ref:`Vector3<class_Vector3>` velocity **)** const
  132. Sets the current velocity of the agent.
  133. ----
  134. .. _class_NavigationServer_method_free:
  135. - void **free** **(** :ref:`RID<class_RID>` object **)** const
  136. Destroy the RID
  137. ----
  138. .. _class_NavigationServer_method_map_create:
  139. - :ref:`RID<class_RID>` **map_create** **(** **)** const
  140. Create a new map.
  141. ----
  142. .. _class_NavigationServer_method_map_get_cell_size:
  143. - :ref:`float<class_float>` **map_get_cell_size** **(** :ref:`RID<class_RID>` map **)** const
  144. Returns the map cell size.
  145. ----
  146. .. _class_NavigationServer_method_map_get_closest_point:
  147. - :ref:`Vector3<class_Vector3>` **map_get_closest_point** **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` to_point **)** const
  148. Returns the point closest to the provided ``point`` on the navigation mesh surface.
  149. ----
  150. .. _class_NavigationServer_method_map_get_closest_point_normal:
  151. - :ref:`Vector3<class_Vector3>` **map_get_closest_point_normal** **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` to_point **)** const
  152. Returns the normal for the point returned by :ref:`map_get_closest_point<class_NavigationServer_method_map_get_closest_point>`.
  153. ----
  154. .. _class_NavigationServer_method_map_get_closest_point_owner:
  155. - :ref:`RID<class_RID>` **map_get_closest_point_owner** **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` to_point **)** const
  156. Returns the owner region RID for the point returned by :ref:`map_get_closest_point<class_NavigationServer_method_map_get_closest_point>`.
  157. ----
  158. .. _class_NavigationServer_method_map_get_closest_point_to_segment:
  159. - :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
  160. Returns the closest point between the navigation surface and the segment.
  161. ----
  162. .. _class_NavigationServer_method_map_get_edge_connection_margin:
  163. - :ref:`float<class_float>` **map_get_edge_connection_margin** **(** :ref:`RID<class_RID>` map **)** const
  164. Returns the edge connection margin of the map.
  165. ----
  166. .. _class_NavigationServer_method_map_get_path:
  167. - :ref:`PackedVector3Array<class_PackedVector3Array>` **map_get_path** **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` origin, :ref:`Vector3<class_Vector3>` destination, :ref:`bool<class_bool>` optimize **)** const
  168. Returns the navigation path to reach the destination from the origin.
  169. ----
  170. .. _class_NavigationServer_method_map_get_up:
  171. - :ref:`Vector3<class_Vector3>` **map_get_up** **(** :ref:`RID<class_RID>` map **)** const
  172. Returns the map's up direction.
  173. ----
  174. .. _class_NavigationServer_method_map_is_active:
  175. - :ref:`bool<class_bool>` **map_is_active** **(** :ref:`RID<class_RID>` nap **)** const
  176. Returns true if the map is active.
  177. ----
  178. .. _class_NavigationServer_method_map_set_active:
  179. - void **map_set_active** **(** :ref:`RID<class_RID>` map, :ref:`bool<class_bool>` active **)** const
  180. Sets the map active.
  181. ----
  182. .. _class_NavigationServer_method_map_set_cell_size:
  183. - void **map_set_cell_size** **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` cell_size **)** const
  184. Set the map cell size used to weld the navigation mesh polygons.
  185. ----
  186. .. _class_NavigationServer_method_map_set_edge_connection_margin:
  187. - void **map_set_edge_connection_margin** **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` margin **)** const
  188. Set the map edge connection margein used to weld the compatible region edges.
  189. ----
  190. .. _class_NavigationServer_method_map_set_up:
  191. - void **map_set_up** **(** :ref:`RID<class_RID>` map, :ref:`Vector3<class_Vector3>` up **)** const
  192. Sets the map up direction.
  193. ----
  194. .. _class_NavigationServer_method_process:
  195. - void **process** **(** :ref:`float<class_float>` delta_time **)**
  196. Process the collision avoidance agents.
  197. The result of this process is needed by the physics server, so this must be called in the main thread.
  198. Note: This function is not thread safe.
  199. ----
  200. .. _class_NavigationServer_method_region_bake_navmesh:
  201. - void **region_bake_navmesh** **(** :ref:`NavigationMesh<class_NavigationMesh>` mesh, :ref:`Node<class_Node>` node **)** const
  202. Bakes the navigation mesh.
  203. ----
  204. .. _class_NavigationServer_method_region_create:
  205. - :ref:`RID<class_RID>` **region_create** **(** **)** const
  206. Creates a new region.
  207. ----
  208. .. _class_NavigationServer_method_region_set_map:
  209. - void **region_set_map** **(** :ref:`RID<class_RID>` region, :ref:`RID<class_RID>` map **)** const
  210. Sets the map for the region.
  211. ----
  212. .. _class_NavigationServer_method_region_set_navmesh:
  213. - void **region_set_navmesh** **(** :ref:`RID<class_RID>` region, :ref:`NavigationMesh<class_NavigationMesh>` nav_mesh **)** const
  214. Sets the navigation mesh for the region.
  215. ----
  216. .. _class_NavigationServer_method_region_set_transform:
  217. - void **region_set_transform** **(** :ref:`RID<class_RID>` region, :ref:`Transform<class_Transform>` transform **)** const
  218. Sets the global transformation for the region.
  219. ----
  220. .. _class_NavigationServer_method_set_active:
  221. - void **set_active** **(** :ref:`bool<class_bool>` active **)** const
  222. Control activation of this server.