class_navigation2dserver.rst 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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 Navigation2DServer.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_Navigation2DServer:
  6. Navigation2DServer
  7. ==================
  8. **Inherits:** :ref:`Object<class_Object>`
  9. Server interface for low-level 2D navigation access
  10. Description
  11. -----------
  12. Navigation2DServer is the server responsible for all 2D 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_Navigation2DServer_method_agent_create>` **(** **)** const |
  17. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`bool<class_bool>` | :ref:`agent_is_map_changed<class_Navigation2DServer_method_agent_is_map_changed>` **(** :ref:`RID<class_RID>` agent **)** const |
  19. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`agent_set_callback<class_Navigation2DServer_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_Navigation2DServer_method_agent_set_map>` **(** :ref:`RID<class_RID>` agent, :ref:`RID<class_RID>` map **)** const |
  23. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`agent_set_max_neighbors<class_Navigation2DServer_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_Navigation2DServer_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_Navigation2DServer_method_agent_set_neighbor_dist>` **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` dist **)** const |
  29. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`agent_set_position<class_Navigation2DServer_method_agent_set_position>` **(** :ref:`RID<class_RID>` agent, :ref:`Vector2<class_Vector2>` position **)** const |
  31. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`agent_set_radius<class_Navigation2DServer_method_agent_set_radius>` **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` radius **)** const |
  33. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | void | :ref:`agent_set_target_velocity<class_Navigation2DServer_method_agent_set_target_velocity>` **(** :ref:`RID<class_RID>` agent, :ref:`Vector2<class_Vector2>` target_velocity **)** const |
  35. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`agent_set_time_horizon<class_Navigation2DServer_method_agent_set_time_horizon>` **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` time **)** const |
  37. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`agent_set_velocity<class_Navigation2DServer_method_agent_set_velocity>` **(** :ref:`RID<class_RID>` agent, :ref:`Vector2<class_Vector2>` velocity **)** const |
  39. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`free<class_Navigation2DServer_method_free>` **(** :ref:`RID<class_RID>` object **)** const |
  41. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`RID<class_RID>` | :ref:`map_create<class_Navigation2DServer_method_map_create>` **(** **)** const |
  43. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`float<class_float>` | :ref:`map_get_cell_size<class_Navigation2DServer_method_map_get_cell_size>` **(** :ref:`RID<class_RID>` map **)** const |
  45. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`Vector2<class_Vector2>` | :ref:`map_get_closest_point<class_Navigation2DServer_method_map_get_closest_point>` **(** :ref:`RID<class_RID>` map, :ref:`Vector2<class_Vector2>` to_point **)** const |
  47. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`RID<class_RID>` | :ref:`map_get_closest_point_owner<class_Navigation2DServer_method_map_get_closest_point_owner>` **(** :ref:`RID<class_RID>` map, :ref:`Vector2<class_Vector2>` to_point **)** const |
  49. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`float<class_float>` | :ref:`map_get_edge_connection_margin<class_Navigation2DServer_method_map_get_edge_connection_margin>` **(** :ref:`RID<class_RID>` map **)** const |
  51. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`PackedVector2Array<class_PackedVector2Array>` | :ref:`map_get_path<class_Navigation2DServer_method_map_get_path>` **(** :ref:`RID<class_RID>` map, :ref:`Vector2<class_Vector2>` origin, :ref:`Vector2<class_Vector2>` destination, :ref:`bool<class_bool>` optimize **)** const |
  53. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`bool<class_bool>` | :ref:`map_is_active<class_Navigation2DServer_method_map_is_active>` **(** :ref:`RID<class_RID>` nap **)** const |
  55. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | void | :ref:`map_set_active<class_Navigation2DServer_method_map_set_active>` **(** :ref:`RID<class_RID>` map, :ref:`bool<class_bool>` active **)** const |
  57. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`map_set_cell_size<class_Navigation2DServer_method_map_set_cell_size>` **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` cell_size **)** const |
  59. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`map_set_edge_connection_margin<class_Navigation2DServer_method_map_set_edge_connection_margin>` **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` margin **)** const |
  61. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`RID<class_RID>` | :ref:`region_create<class_Navigation2DServer_method_region_create>` **(** **)** const |
  63. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | void | :ref:`region_set_map<class_Navigation2DServer_method_region_set_map>` **(** :ref:`RID<class_RID>` region, :ref:`RID<class_RID>` map **)** const |
  65. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | void | :ref:`region_set_navpoly<class_Navigation2DServer_method_region_set_navpoly>` **(** :ref:`RID<class_RID>` region, :ref:`NavigationPolygon<class_NavigationPolygon>` nav_poly **)** const |
  67. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | void | :ref:`region_set_transform<class_Navigation2DServer_method_region_set_transform>` **(** :ref:`RID<class_RID>` region, :ref:`Transform2D<class_Transform2D>` transform **)** const |
  69. +-----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. Method Descriptions
  71. -------------------
  72. .. _class_Navigation2DServer_method_agent_create:
  73. - :ref:`RID<class_RID>` **agent_create** **(** **)** const
  74. Creates the agent.
  75. ----
  76. .. _class_Navigation2DServer_method_agent_is_map_changed:
  77. - :ref:`bool<class_bool>` **agent_is_map_changed** **(** :ref:`RID<class_RID>` agent **)** const
  78. Returns true if the map got changed the previous frame.
  79. ----
  80. .. _class_Navigation2DServer_method_agent_set_callback:
  81. - 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
  82. Callback called at the end of the RVO process.
  83. ----
  84. .. _class_Navigation2DServer_method_agent_set_map:
  85. - void **agent_set_map** **(** :ref:`RID<class_RID>` agent, :ref:`RID<class_RID>` map **)** const
  86. Puts the agent in the map.
  87. ----
  88. .. _class_Navigation2DServer_method_agent_set_max_neighbors:
  89. - void **agent_set_max_neighbors** **(** :ref:`RID<class_RID>` agent, :ref:`int<class_int>` count **)** const
  90. 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.
  91. ----
  92. .. _class_Navigation2DServer_method_agent_set_max_speed:
  93. - void **agent_set_max_speed** **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` max_speed **)** const
  94. Sets the maximum speed of the agent. Must be positive.
  95. ----
  96. .. _class_Navigation2DServer_method_agent_set_neighbor_dist:
  97. - void **agent_set_neighbor_dist** **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` dist **)** const
  98. 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.
  99. ----
  100. .. _class_Navigation2DServer_method_agent_set_position:
  101. - void **agent_set_position** **(** :ref:`RID<class_RID>` agent, :ref:`Vector2<class_Vector2>` position **)** const
  102. Sets the position of the agent in world space.
  103. ----
  104. .. _class_Navigation2DServer_method_agent_set_radius:
  105. - void **agent_set_radius** **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` radius **)** const
  106. Sets the radius of the agent.
  107. ----
  108. .. _class_Navigation2DServer_method_agent_set_target_velocity:
  109. - void **agent_set_target_velocity** **(** :ref:`RID<class_RID>` agent, :ref:`Vector2<class_Vector2>` target_velocity **)** const
  110. Sets the new target velocity.
  111. ----
  112. .. _class_Navigation2DServer_method_agent_set_time_horizon:
  113. - void **agent_set_time_horizon** **(** :ref:`RID<class_RID>` agent, :ref:`float<class_float>` time **)** const
  114. 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.
  115. ----
  116. .. _class_Navigation2DServer_method_agent_set_velocity:
  117. - void **agent_set_velocity** **(** :ref:`RID<class_RID>` agent, :ref:`Vector2<class_Vector2>` velocity **)** const
  118. Sets the current velocity of the agent.
  119. ----
  120. .. _class_Navigation2DServer_method_free:
  121. - void **free** **(** :ref:`RID<class_RID>` object **)** const
  122. Destroy the RID
  123. ----
  124. .. _class_Navigation2DServer_method_map_create:
  125. - :ref:`RID<class_RID>` **map_create** **(** **)** const
  126. Create a new map.
  127. ----
  128. .. _class_Navigation2DServer_method_map_get_cell_size:
  129. - :ref:`float<class_float>` **map_get_cell_size** **(** :ref:`RID<class_RID>` map **)** const
  130. Returns the map cell size.
  131. ----
  132. .. _class_Navigation2DServer_method_map_get_closest_point:
  133. - :ref:`Vector2<class_Vector2>` **map_get_closest_point** **(** :ref:`RID<class_RID>` map, :ref:`Vector2<class_Vector2>` to_point **)** const
  134. Returns the point closest to the provided ``to_point`` on the navigation mesh surface.
  135. ----
  136. .. _class_Navigation2DServer_method_map_get_closest_point_owner:
  137. - :ref:`RID<class_RID>` **map_get_closest_point_owner** **(** :ref:`RID<class_RID>` map, :ref:`Vector2<class_Vector2>` to_point **)** const
  138. Returns the owner region RID for the point returned by :ref:`map_get_closest_point<class_Navigation2DServer_method_map_get_closest_point>`.
  139. ----
  140. .. _class_Navigation2DServer_method_map_get_edge_connection_margin:
  141. - :ref:`float<class_float>` **map_get_edge_connection_margin** **(** :ref:`RID<class_RID>` map **)** const
  142. Returns the edge connection margin of the map. The edge connection margin is a distance used to connect two regions.
  143. ----
  144. .. _class_Navigation2DServer_method_map_get_path:
  145. - :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 **)** const
  146. Returns the navigation path to reach the destination from the origin, while avoiding static obstacles.
  147. ----
  148. .. _class_Navigation2DServer_method_map_is_active:
  149. - :ref:`bool<class_bool>` **map_is_active** **(** :ref:`RID<class_RID>` nap **)** const
  150. Returns true if the map is active.
  151. ----
  152. .. _class_Navigation2DServer_method_map_set_active:
  153. - void **map_set_active** **(** :ref:`RID<class_RID>` map, :ref:`bool<class_bool>` active **)** const
  154. Sets the map active.
  155. ----
  156. .. _class_Navigation2DServer_method_map_set_cell_size:
  157. - void **map_set_cell_size** **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` cell_size **)** const
  158. Set the map cell size used to weld the navigation mesh polygons.
  159. ----
  160. .. _class_Navigation2DServer_method_map_set_edge_connection_margin:
  161. - void **map_set_edge_connection_margin** **(** :ref:`RID<class_RID>` map, :ref:`float<class_float>` margin **)** const
  162. Set the map edge connection margin used to weld the compatible region edges.
  163. ----
  164. .. _class_Navigation2DServer_method_region_create:
  165. - :ref:`RID<class_RID>` **region_create** **(** **)** const
  166. Creates a new region.
  167. ----
  168. .. _class_Navigation2DServer_method_region_set_map:
  169. - void **region_set_map** **(** :ref:`RID<class_RID>` region, :ref:`RID<class_RID>` map **)** const
  170. Sets the map for the region.
  171. ----
  172. .. _class_Navigation2DServer_method_region_set_navpoly:
  173. - void **region_set_navpoly** **(** :ref:`RID<class_RID>` region, :ref:`NavigationPolygon<class_NavigationPolygon>` nav_poly **)** const
  174. Sets the navigation mesh for the region.
  175. ----
  176. .. _class_Navigation2DServer_method_region_set_transform:
  177. - void **region_set_transform** **(** :ref:`RID<class_RID>` region, :ref:`Transform2D<class_Transform2D>` transform **)** const
  178. Sets the global transformation for the region.