class_navigationagent2d.rst 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/NavigationAgent2D.xml.
  6. .. _class_NavigationAgent2D:
  7. NavigationAgent2D
  8. =================
  9. **Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. 2D Agent used in navigation for collision avoidance.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. 2D Agent that is used in navigation to reach a location while avoiding static and dynamic obstacles. The dynamic obstacles are avoided using RVO collision avoidance. The agent needs navigation data to work correctly. **NavigationAgent2D** is physics safe.
  15. \ **Note:** After setting :ref:`target_location<class_NavigationAgent2D_property_target_location>` it is required to use the :ref:`get_next_location<class_NavigationAgent2D_method_get_next_location>` function once every physics frame to update the internal path logic of the NavigationAgent. The returned vector position from this function should be used as the next movement position for the agent's parent Node.
  16. .. rst-class:: classref-reftable-group
  17. Properties
  18. ----------
  19. .. table::
  20. :widths: auto
  21. +----------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+-------------------+
  22. | :ref:`bool<class_bool>` | :ref:`avoidance_enabled<class_NavigationAgent2D_property_avoidance_enabled>` | ``false`` |
  23. +----------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+-------------------+
  24. | :ref:`int<class_int>` | :ref:`max_neighbors<class_NavigationAgent2D_property_max_neighbors>` | ``10`` |
  25. +----------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+-------------------+
  26. | :ref:`float<class_float>` | :ref:`max_speed<class_NavigationAgent2D_property_max_speed>` | ``200.0`` |
  27. +----------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+-------------------+
  28. | :ref:`int<class_int>` | :ref:`navigation_layers<class_NavigationAgent2D_property_navigation_layers>` | ``1`` |
  29. +----------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+-------------------+
  30. | :ref:`float<class_float>` | :ref:`neighbor_distance<class_NavigationAgent2D_property_neighbor_distance>` | ``500.0`` |
  31. +----------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+-------------------+
  32. | :ref:`float<class_float>` | :ref:`path_desired_distance<class_NavigationAgent2D_property_path_desired_distance>` | ``1.0`` |
  33. +----------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+-------------------+
  34. | :ref:`float<class_float>` | :ref:`path_max_distance<class_NavigationAgent2D_property_path_max_distance>` | ``3.0`` |
  35. +----------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+-------------------+
  36. | :ref:`PathMetadataFlags<enum_NavigationPathQueryParameters2D_PathMetadataFlags>` | :ref:`path_metadata_flags<class_NavigationAgent2D_property_path_metadata_flags>` | ``7`` |
  37. +----------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+-------------------+
  38. | :ref:`float<class_float>` | :ref:`radius<class_NavigationAgent2D_property_radius>` | ``10.0`` |
  39. +----------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+-------------------+
  40. | :ref:`float<class_float>` | :ref:`target_desired_distance<class_NavigationAgent2D_property_target_desired_distance>` | ``1.0`` |
  41. +----------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+-------------------+
  42. | :ref:`Vector2<class_Vector2>` | :ref:`target_location<class_NavigationAgent2D_property_target_location>` | ``Vector2(0, 0)`` |
  43. +----------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+-------------------+
  44. | :ref:`float<class_float>` | :ref:`time_horizon<class_NavigationAgent2D_property_time_horizon>` | ``20.0`` |
  45. +----------------------------------------------------------------------------------+------------------------------------------------------------------------------------------+-------------------+
  46. .. rst-class:: classref-reftable-group
  47. Methods
  48. -------
  49. .. table::
  50. :widths: auto
  51. +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`float<class_float>` | :ref:`distance_to_target<class_NavigationAgent2D_method_distance_to_target>` **(** **)** |const| |
  53. +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`PackedVector2Array<class_PackedVector2Array>` | :ref:`get_current_navigation_path<class_NavigationAgent2D_method_get_current_navigation_path>` **(** **)** |const| |
  55. +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`int<class_int>` | :ref:`get_current_navigation_path_index<class_NavigationAgent2D_method_get_current_navigation_path_index>` **(** **)** |const| |
  57. +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`NavigationPathQueryResult2D<class_NavigationPathQueryResult2D>` | :ref:`get_current_navigation_result<class_NavigationAgent2D_method_get_current_navigation_result>` **(** **)** |const| |
  59. +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`Vector2<class_Vector2>` | :ref:`get_final_location<class_NavigationAgent2D_method_get_final_location>` **(** **)** |
  61. +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`bool<class_bool>` | :ref:`get_navigation_layer_value<class_NavigationAgent2D_method_get_navigation_layer_value>` **(** :ref:`int<class_int>` layer_number **)** |const| |
  63. +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`RID<class_RID>` | :ref:`get_navigation_map<class_NavigationAgent2D_method_get_navigation_map>` **(** **)** |const| |
  65. +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`Vector2<class_Vector2>` | :ref:`get_next_location<class_NavigationAgent2D_method_get_next_location>` **(** **)** |
  67. +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`RID<class_RID>` | :ref:`get_rid<class_NavigationAgent2D_method_get_rid>` **(** **)** |const| |
  69. +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`bool<class_bool>` | :ref:`is_navigation_finished<class_NavigationAgent2D_method_is_navigation_finished>` **(** **)** |
  71. +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`bool<class_bool>` | :ref:`is_target_reachable<class_NavigationAgent2D_method_is_target_reachable>` **(** **)** |
  73. +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`bool<class_bool>` | :ref:`is_target_reached<class_NavigationAgent2D_method_is_target_reached>` **(** **)** |const| |
  75. +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | void | :ref:`set_navigation_layer_value<class_NavigationAgent2D_method_set_navigation_layer_value>` **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)** |
  77. +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | void | :ref:`set_navigation_map<class_NavigationAgent2D_method_set_navigation_map>` **(** :ref:`RID<class_RID>` navigation_map **)** |
  79. +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | void | :ref:`set_velocity<class_NavigationAgent2D_method_set_velocity>` **(** :ref:`Vector2<class_Vector2>` velocity **)** |
  81. +-----------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. .. rst-class:: classref-section-separator
  83. ----
  84. .. rst-class:: classref-descriptions-group
  85. Signals
  86. -------
  87. .. _class_NavigationAgent2D_signal_link_reached:
  88. .. rst-class:: classref-signal
  89. **link_reached** **(** :ref:`Dictionary<class_Dictionary>` details **)**
  90. Notifies when a navigation link has been reached.
  91. The details dictionary may contain the following keys depending on the value of :ref:`path_metadata_flags<class_NavigationAgent2D_property_path_metadata_flags>`:
  92. - ``location``: The start location of the link that was reached.
  93. - ``type``: Always :ref:`NavigationPathQueryResult2D.PATH_SEGMENT_TYPE_LINK<class_NavigationPathQueryResult2D_constant_PATH_SEGMENT_TYPE_LINK>`.
  94. - ``rid``: The :ref:`RID<class_RID>` of the link.
  95. - ``owner``: The object which manages the link (usually :ref:`NavigationLink2D<class_NavigationLink2D>`).
  96. .. rst-class:: classref-item-separator
  97. ----
  98. .. _class_NavigationAgent2D_signal_navigation_finished:
  99. .. rst-class:: classref-signal
  100. **navigation_finished** **(** **)**
  101. Notifies when the final location is reached.
  102. .. rst-class:: classref-item-separator
  103. ----
  104. .. _class_NavigationAgent2D_signal_path_changed:
  105. .. rst-class:: classref-signal
  106. **path_changed** **(** **)**
  107. Notifies when the navigation path changes.
  108. .. rst-class:: classref-item-separator
  109. ----
  110. .. _class_NavigationAgent2D_signal_target_reached:
  111. .. rst-class:: classref-signal
  112. **target_reached** **(** **)**
  113. Notifies when the player-defined :ref:`target_location<class_NavigationAgent2D_property_target_location>` is reached.
  114. .. rst-class:: classref-item-separator
  115. ----
  116. .. _class_NavigationAgent2D_signal_velocity_computed:
  117. .. rst-class:: classref-signal
  118. **velocity_computed** **(** :ref:`Vector2<class_Vector2>` safe_velocity **)**
  119. Notifies when the collision avoidance velocity is calculated. Emitted by :ref:`set_velocity<class_NavigationAgent2D_method_set_velocity>`. Only emitted when :ref:`avoidance_enabled<class_NavigationAgent2D_property_avoidance_enabled>` is true.
  120. .. rst-class:: classref-item-separator
  121. ----
  122. .. _class_NavigationAgent2D_signal_waypoint_reached:
  123. .. rst-class:: classref-signal
  124. **waypoint_reached** **(** :ref:`Dictionary<class_Dictionary>` details **)**
  125. Notifies when a waypoint along the path has been reached.
  126. The details dictionary may contain the following keys depending on the value of :ref:`path_metadata_flags<class_NavigationAgent2D_property_path_metadata_flags>`:
  127. - ``location``: The location of the waypoint that was reached.
  128. - ``type``: The type of navigation primitive (region or link) that contains this waypoint.
  129. - ``rid``: The :ref:`RID<class_RID>` of the containing navigation primitive (region or link).
  130. - ``owner``: The object which manages the containing navigation primitive (region or link).
  131. .. rst-class:: classref-section-separator
  132. ----
  133. .. rst-class:: classref-descriptions-group
  134. Property Descriptions
  135. ---------------------
  136. .. _class_NavigationAgent2D_property_avoidance_enabled:
  137. .. rst-class:: classref-property
  138. :ref:`bool<class_bool>` **avoidance_enabled** = ``false``
  139. .. rst-class:: classref-property-setget
  140. - void **set_avoidance_enabled** **(** :ref:`bool<class_bool>` value **)**
  141. - :ref:`bool<class_bool>` **get_avoidance_enabled** **(** **)**
  142. If ``true`` the agent is registered for an RVO avoidance callback on the :ref:`NavigationServer2D<class_NavigationServer2D>`. When :ref:`set_velocity<class_NavigationAgent2D_method_set_velocity>` is used and the processing is completed a ``safe_velocity`` Vector2 is received with a signal connection to :ref:`velocity_computed<class_NavigationAgent2D_signal_velocity_computed>`. Avoidance processing with many registered agents has a significant performance cost and should only be enabled on agents that currently require it.
  143. .. rst-class:: classref-item-separator
  144. ----
  145. .. _class_NavigationAgent2D_property_max_neighbors:
  146. .. rst-class:: classref-property
  147. :ref:`int<class_int>` **max_neighbors** = ``10``
  148. .. rst-class:: classref-property-setget
  149. - void **set_max_neighbors** **(** :ref:`int<class_int>` value **)**
  150. - :ref:`int<class_int>` **get_max_neighbors** **(** **)**
  151. The maximum number of neighbors for the agent to consider.
  152. .. rst-class:: classref-item-separator
  153. ----
  154. .. _class_NavigationAgent2D_property_max_speed:
  155. .. rst-class:: classref-property
  156. :ref:`float<class_float>` **max_speed** = ``200.0``
  157. .. rst-class:: classref-property-setget
  158. - void **set_max_speed** **(** :ref:`float<class_float>` value **)**
  159. - :ref:`float<class_float>` **get_max_speed** **(** **)**
  160. The maximum speed that an agent can move.
  161. .. rst-class:: classref-item-separator
  162. ----
  163. .. _class_NavigationAgent2D_property_navigation_layers:
  164. .. rst-class:: classref-property
  165. :ref:`int<class_int>` **navigation_layers** = ``1``
  166. .. rst-class:: classref-property-setget
  167. - void **set_navigation_layers** **(** :ref:`int<class_int>` value **)**
  168. - :ref:`int<class_int>` **get_navigation_layers** **(** **)**
  169. A bitfield determining what navigation layers of navigation regions this agent will use to calculate path. Changing it runtime will clear current navigation path and generate new one, according to new navigation layers.
  170. .. rst-class:: classref-item-separator
  171. ----
  172. .. _class_NavigationAgent2D_property_neighbor_distance:
  173. .. rst-class:: classref-property
  174. :ref:`float<class_float>` **neighbor_distance** = ``500.0``
  175. .. rst-class:: classref-property-setget
  176. - void **set_neighbor_distance** **(** :ref:`float<class_float>` value **)**
  177. - :ref:`float<class_float>` **get_neighbor_distance** **(** **)**
  178. The distance to search for other agents.
  179. .. rst-class:: classref-item-separator
  180. ----
  181. .. _class_NavigationAgent2D_property_path_desired_distance:
  182. .. rst-class:: classref-property
  183. :ref:`float<class_float>` **path_desired_distance** = ``1.0``
  184. .. rst-class:: classref-property-setget
  185. - void **set_path_desired_distance** **(** :ref:`float<class_float>` value **)**
  186. - :ref:`float<class_float>` **get_path_desired_distance** **(** **)**
  187. The distance threshold before a path point is considered to be reached. This will allow an agent to not have to hit a path point on the path exactly, but in the area. If this value is set to high the NavigationAgent will skip points on the path which can lead to leaving the navigation mesh. If this value is set to low the NavigationAgent will be stuck in a repath loop cause it will constantly overshoot or undershoot the distance to the next point on each physics frame update.
  188. .. rst-class:: classref-item-separator
  189. ----
  190. .. _class_NavigationAgent2D_property_path_max_distance:
  191. .. rst-class:: classref-property
  192. :ref:`float<class_float>` **path_max_distance** = ``3.0``
  193. .. rst-class:: classref-property-setget
  194. - void **set_path_max_distance** **(** :ref:`float<class_float>` value **)**
  195. - :ref:`float<class_float>` **get_path_max_distance** **(** **)**
  196. The maximum distance the agent is allowed away from the ideal path to the final location. This can happen due to trying to avoid collisions. When the maximum distance is exceeded, it recalculates the ideal path.
  197. .. rst-class:: classref-item-separator
  198. ----
  199. .. _class_NavigationAgent2D_property_path_metadata_flags:
  200. .. rst-class:: classref-property
  201. :ref:`PathMetadataFlags<enum_NavigationPathQueryParameters2D_PathMetadataFlags>` **path_metadata_flags** = ``7``
  202. .. rst-class:: classref-property-setget
  203. - void **set_path_metadata_flags** **(** :ref:`PathMetadataFlags<enum_NavigationPathQueryParameters2D_PathMetadataFlags>` value **)**
  204. - :ref:`PathMetadataFlags<enum_NavigationPathQueryParameters2D_PathMetadataFlags>` **get_path_metadata_flags** **(** **)**
  205. Additional information to return with the navigation path.
  206. .. rst-class:: classref-item-separator
  207. ----
  208. .. _class_NavigationAgent2D_property_radius:
  209. .. rst-class:: classref-property
  210. :ref:`float<class_float>` **radius** = ``10.0``
  211. .. rst-class:: classref-property-setget
  212. - void **set_radius** **(** :ref:`float<class_float>` value **)**
  213. - :ref:`float<class_float>` **get_radius** **(** **)**
  214. The radius of the avoidance agent. This is the "body" of the avoidance agent and not the avoidance maneuver starting radius (which is controlled by :ref:`neighbor_distance<class_NavigationAgent2D_property_neighbor_distance>`).
  215. Does not affect normal pathfinding. To change an actor's pathfinding radius bake :ref:`NavigationMesh<class_NavigationMesh>` resources with a different :ref:`NavigationMesh.agent_radius<class_NavigationMesh_property_agent_radius>` property and use different navigation maps for each actor size.
  216. .. rst-class:: classref-item-separator
  217. ----
  218. .. _class_NavigationAgent2D_property_target_desired_distance:
  219. .. rst-class:: classref-property
  220. :ref:`float<class_float>` **target_desired_distance** = ``1.0``
  221. .. rst-class:: classref-property-setget
  222. - void **set_target_desired_distance** **(** :ref:`float<class_float>` value **)**
  223. - :ref:`float<class_float>` **get_target_desired_distance** **(** **)**
  224. The distance threshold before the final target point is considered to be reached. This will allow an agent to not have to hit the point of the final target exactly, but only the area. If this value is set to low the NavigationAgent will be stuck in a repath loop cause it will constantly overshoot or undershoot the distance to the final target point on each physics frame update.
  225. .. rst-class:: classref-item-separator
  226. ----
  227. .. _class_NavigationAgent2D_property_target_location:
  228. .. rst-class:: classref-property
  229. :ref:`Vector2<class_Vector2>` **target_location** = ``Vector2(0, 0)``
  230. .. rst-class:: classref-property-setget
  231. - void **set_target_location** **(** :ref:`Vector2<class_Vector2>` value **)**
  232. - :ref:`Vector2<class_Vector2>` **get_target_location** **(** **)**
  233. The user-defined target location. Setting this property will clear the current navigation path.
  234. .. rst-class:: classref-item-separator
  235. ----
  236. .. _class_NavigationAgent2D_property_time_horizon:
  237. .. rst-class:: classref-property
  238. :ref:`float<class_float>` **time_horizon** = ``20.0``
  239. .. rst-class:: classref-property-setget
  240. - void **set_time_horizon** **(** :ref:`float<class_float>` value **)**
  241. - :ref:`float<class_float>` **get_time_horizon** **(** **)**
  242. The minimal amount of time for which this agent's velocities, that are computed with the collision avoidance algorithm, are safe with respect to other agents. The larger the number, the sooner the agent will respond to other agents, but less freedom in choosing its velocities. Must be positive.
  243. .. rst-class:: classref-section-separator
  244. ----
  245. .. rst-class:: classref-descriptions-group
  246. Method Descriptions
  247. -------------------
  248. .. _class_NavigationAgent2D_method_distance_to_target:
  249. .. rst-class:: classref-method
  250. :ref:`float<class_float>` **distance_to_target** **(** **)** |const|
  251. Returns the distance to the target location, using the agent's global position. The user must set :ref:`target_location<class_NavigationAgent2D_property_target_location>` in order for this to be accurate.
  252. .. rst-class:: classref-item-separator
  253. ----
  254. .. _class_NavigationAgent2D_method_get_current_navigation_path:
  255. .. rst-class:: classref-method
  256. :ref:`PackedVector2Array<class_PackedVector2Array>` **get_current_navigation_path** **(** **)** |const|
  257. Returns this agent's current path from start to finish in global coordinates. The path only updates when the target location is changed or the agent requires a repath. The path array is not intended to be used in direct path movement as the agent has its own internal path logic that would get corrupted by changing the path array manually. Use the intended :ref:`get_next_location<class_NavigationAgent2D_method_get_next_location>` once every physics frame to receive the next path point for the agents movement as this function also updates the internal path logic.
  258. .. rst-class:: classref-item-separator
  259. ----
  260. .. _class_NavigationAgent2D_method_get_current_navigation_path_index:
  261. .. rst-class:: classref-method
  262. :ref:`int<class_int>` **get_current_navigation_path_index** **(** **)** |const|
  263. Returns which index the agent is currently on in the navigation path's :ref:`PackedVector2Array<class_PackedVector2Array>`.
  264. .. rst-class:: classref-item-separator
  265. ----
  266. .. _class_NavigationAgent2D_method_get_current_navigation_result:
  267. .. rst-class:: classref-method
  268. :ref:`NavigationPathQueryResult2D<class_NavigationPathQueryResult2D>` **get_current_navigation_result** **(** **)** |const|
  269. Returns the path query result for the path the agent is currently following.
  270. .. rst-class:: classref-item-separator
  271. ----
  272. .. _class_NavigationAgent2D_method_get_final_location:
  273. .. rst-class:: classref-method
  274. :ref:`Vector2<class_Vector2>` **get_final_location** **(** **)**
  275. Returns the reachable final location in global coordinates. This can change if the navigation path is altered in any way. Because of this, it would be best to check this each frame.
  276. .. rst-class:: classref-item-separator
  277. ----
  278. .. _class_NavigationAgent2D_method_get_navigation_layer_value:
  279. .. rst-class:: classref-method
  280. :ref:`bool<class_bool>` **get_navigation_layer_value** **(** :ref:`int<class_int>` layer_number **)** |const|
  281. Returns whether or not the specified layer of the :ref:`navigation_layers<class_NavigationAgent2D_property_navigation_layers>` bitmask is enabled, given a ``layer_number`` between 1 and 32.
  282. .. rst-class:: classref-item-separator
  283. ----
  284. .. _class_NavigationAgent2D_method_get_navigation_map:
  285. .. rst-class:: classref-method
  286. :ref:`RID<class_RID>` **get_navigation_map** **(** **)** |const|
  287. Returns the :ref:`RID<class_RID>` of the navigation map for this NavigationAgent node. This function returns always the map set on the NavigationAgent node and not the map of the abstract agent on the NavigationServer. If the agent map is changed directly with the NavigationServer API the NavigationAgent node will not be aware of the map change. Use :ref:`set_navigation_map<class_NavigationAgent2D_method_set_navigation_map>` to change the navigation map for the NavigationAgent and also update the agent on the NavigationServer.
  288. .. rst-class:: classref-item-separator
  289. ----
  290. .. _class_NavigationAgent2D_method_get_next_location:
  291. .. rst-class:: classref-method
  292. :ref:`Vector2<class_Vector2>` **get_next_location** **(** **)**
  293. Returns the next location in global coordinates that can be moved to, making sure that there are no static objects in the way. If the agent does not have a navigation path, it will return the position of the agent's parent. The use of this function once every physics frame is required to update the internal path logic of the NavigationAgent.
  294. .. rst-class:: classref-item-separator
  295. ----
  296. .. _class_NavigationAgent2D_method_get_rid:
  297. .. rst-class:: classref-method
  298. :ref:`RID<class_RID>` **get_rid** **(** **)** |const|
  299. Returns the :ref:`RID<class_RID>` of this agent on the :ref:`NavigationServer2D<class_NavigationServer2D>`.
  300. .. rst-class:: classref-item-separator
  301. ----
  302. .. _class_NavigationAgent2D_method_is_navigation_finished:
  303. .. rst-class:: classref-method
  304. :ref:`bool<class_bool>` **is_navigation_finished** **(** **)**
  305. Returns true if the navigation path's final location has been reached.
  306. .. rst-class:: classref-item-separator
  307. ----
  308. .. _class_NavigationAgent2D_method_is_target_reachable:
  309. .. rst-class:: classref-method
  310. :ref:`bool<class_bool>` **is_target_reachable** **(** **)**
  311. Returns true if :ref:`target_location<class_NavigationAgent2D_property_target_location>` is reachable.
  312. .. rst-class:: classref-item-separator
  313. ----
  314. .. _class_NavigationAgent2D_method_is_target_reached:
  315. .. rst-class:: classref-method
  316. :ref:`bool<class_bool>` **is_target_reached** **(** **)** |const|
  317. Returns true if :ref:`target_location<class_NavigationAgent2D_property_target_location>` is reached. It may not always be possible to reach the target location. It should always be possible to reach the final location though. See :ref:`get_final_location<class_NavigationAgent2D_method_get_final_location>`.
  318. .. rst-class:: classref-item-separator
  319. ----
  320. .. _class_NavigationAgent2D_method_set_navigation_layer_value:
  321. .. rst-class:: classref-method
  322. void **set_navigation_layer_value** **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)**
  323. Based on ``value``, enables or disables the specified layer in the :ref:`navigation_layers<class_NavigationAgent2D_property_navigation_layers>` bitmask, given a ``layer_number`` between 1 and 32.
  324. .. rst-class:: classref-item-separator
  325. ----
  326. .. _class_NavigationAgent2D_method_set_navigation_map:
  327. .. rst-class:: classref-method
  328. void **set_navigation_map** **(** :ref:`RID<class_RID>` navigation_map **)**
  329. Sets the :ref:`RID<class_RID>` of the navigation map this NavigationAgent node should use and also updates the ``agent`` on the NavigationServer.
  330. .. rst-class:: classref-item-separator
  331. ----
  332. .. _class_NavigationAgent2D_method_set_velocity:
  333. .. rst-class:: classref-method
  334. void **set_velocity** **(** :ref:`Vector2<class_Vector2>` velocity **)**
  335. Sends the passed in velocity to the collision avoidance algorithm. It will adjust the velocity to avoid collisions. Once the adjustment to the velocity is complete, it will emit the :ref:`velocity_computed<class_NavigationAgent2D_signal_velocity_computed>` signal.
  336. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  337. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  338. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  339. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  340. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  341. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`