class_navigationagent2d.rst 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050
  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. **Experimental:** This class may be changed or removed in future versions.
  10. **Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  11. A 2D agent used to pathfind to a position while avoiding obstacles.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. A 2D agent used to pathfind to a position while avoiding static and dynamic obstacles. The calculation can be used by the parent node to dynamically move it along the path. Requires navigation data to work correctly.
  16. Dynamic obstacles are avoided using RVO collision avoidance. Avoidance is computed before physics, so the pathfinding information can be used safely in the physics step.
  17. \ **Note:** After setting the :ref:`target_position<class_NavigationAgent2D_property_target_position>` property, the :ref:`get_next_path_position()<class_NavigationAgent2D_method_get_next_path_position>` method must be used once every physics frame to update the internal path logic of the navigation agent. The vector position it returns should be used as the next movement position for the agent's parent node.
  18. .. rst-class:: classref-introduction-group
  19. Tutorials
  20. ---------
  21. - :doc:`Using NavigationAgents <../tutorials/navigation/navigation_using_navigationagents>`
  22. .. rst-class:: classref-reftable-group
  23. Properties
  24. ----------
  25. .. table::
  26. :widths: auto
  27. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  28. | :ref:`bool<class_bool>` | :ref:`avoidance_enabled<class_NavigationAgent2D_property_avoidance_enabled>` | ``false`` |
  29. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  30. | :ref:`int<class_int>` | :ref:`avoidance_layers<class_NavigationAgent2D_property_avoidance_layers>` | ``1`` |
  31. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  32. | :ref:`int<class_int>` | :ref:`avoidance_mask<class_NavigationAgent2D_property_avoidance_mask>` | ``1`` |
  33. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  34. | :ref:`float<class_float>` | :ref:`avoidance_priority<class_NavigationAgent2D_property_avoidance_priority>` | ``1.0`` |
  35. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  36. | :ref:`bool<class_bool>` | :ref:`debug_enabled<class_NavigationAgent2D_property_debug_enabled>` | ``false`` |
  37. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  38. | :ref:`Color<class_Color>` | :ref:`debug_path_custom_color<class_NavigationAgent2D_property_debug_path_custom_color>` | ``Color(1, 1, 1, 1)`` |
  39. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  40. | :ref:`float<class_float>` | :ref:`debug_path_custom_line_width<class_NavigationAgent2D_property_debug_path_custom_line_width>` | ``-1.0`` |
  41. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  42. | :ref:`float<class_float>` | :ref:`debug_path_custom_point_size<class_NavigationAgent2D_property_debug_path_custom_point_size>` | ``4.0`` |
  43. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  44. | :ref:`bool<class_bool>` | :ref:`debug_use_custom<class_NavigationAgent2D_property_debug_use_custom>` | ``false`` |
  45. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  46. | :ref:`int<class_int>` | :ref:`max_neighbors<class_NavigationAgent2D_property_max_neighbors>` | ``10`` |
  47. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  48. | :ref:`float<class_float>` | :ref:`max_speed<class_NavigationAgent2D_property_max_speed>` | ``100.0`` |
  49. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  50. | :ref:`int<class_int>` | :ref:`navigation_layers<class_NavigationAgent2D_property_navigation_layers>` | ``1`` |
  51. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  52. | :ref:`float<class_float>` | :ref:`neighbor_distance<class_NavigationAgent2D_property_neighbor_distance>` | ``500.0`` |
  53. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  54. | :ref:`float<class_float>` | :ref:`path_desired_distance<class_NavigationAgent2D_property_path_desired_distance>` | ``20.0`` |
  55. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  56. | :ref:`float<class_float>` | :ref:`path_max_distance<class_NavigationAgent2D_property_path_max_distance>` | ``100.0`` |
  57. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  58. | |bitfield|\[:ref:`PathMetadataFlags<enum_NavigationPathQueryParameters2D_PathMetadataFlags>`\] | :ref:`path_metadata_flags<class_NavigationAgent2D_property_path_metadata_flags>` | ``7`` |
  59. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  60. | :ref:`PathPostProcessing<enum_NavigationPathQueryParameters2D_PathPostProcessing>` | :ref:`path_postprocessing<class_NavigationAgent2D_property_path_postprocessing>` | ``0`` |
  61. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  62. | :ref:`float<class_float>` | :ref:`path_return_max_length<class_NavigationAgent2D_property_path_return_max_length>` | ``0.0`` |
  63. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  64. | :ref:`float<class_float>` | :ref:`path_return_max_radius<class_NavigationAgent2D_property_path_return_max_radius>` | ``0.0`` |
  65. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  66. | :ref:`float<class_float>` | :ref:`path_search_max_distance<class_NavigationAgent2D_property_path_search_max_distance>` | ``0.0`` |
  67. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  68. | :ref:`int<class_int>` | :ref:`path_search_max_polygons<class_NavigationAgent2D_property_path_search_max_polygons>` | ``4096`` |
  69. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  70. | :ref:`PathfindingAlgorithm<enum_NavigationPathQueryParameters2D_PathfindingAlgorithm>` | :ref:`pathfinding_algorithm<class_NavigationAgent2D_property_pathfinding_algorithm>` | ``0`` |
  71. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  72. | :ref:`float<class_float>` | :ref:`radius<class_NavigationAgent2D_property_radius>` | ``10.0`` |
  73. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  74. | :ref:`float<class_float>` | :ref:`simplify_epsilon<class_NavigationAgent2D_property_simplify_epsilon>` | ``0.0`` |
  75. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  76. | :ref:`bool<class_bool>` | :ref:`simplify_path<class_NavigationAgent2D_property_simplify_path>` | ``false`` |
  77. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  78. | :ref:`float<class_float>` | :ref:`target_desired_distance<class_NavigationAgent2D_property_target_desired_distance>` | ``10.0`` |
  79. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  80. | :ref:`Vector2<class_Vector2>` | :ref:`target_position<class_NavigationAgent2D_property_target_position>` | ``Vector2(0, 0)`` |
  81. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  82. | :ref:`float<class_float>` | :ref:`time_horizon_agents<class_NavigationAgent2D_property_time_horizon_agents>` | ``1.0`` |
  83. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  84. | :ref:`float<class_float>` | :ref:`time_horizon_obstacles<class_NavigationAgent2D_property_time_horizon_obstacles>` | ``0.0`` |
  85. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  86. | :ref:`Vector2<class_Vector2>` | :ref:`velocity<class_NavigationAgent2D_property_velocity>` | ``Vector2(0, 0)`` |
  87. +------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+-----------------------+
  88. .. rst-class:: classref-reftable-group
  89. Methods
  90. -------
  91. .. table::
  92. :widths: auto
  93. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | :ref:`float<class_float>` | :ref:`distance_to_target<class_NavigationAgent2D_method_distance_to_target>`\ (\ ) |const| |
  95. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | :ref:`bool<class_bool>` | :ref:`get_avoidance_layer_value<class_NavigationAgent2D_method_get_avoidance_layer_value>`\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| |
  97. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | :ref:`bool<class_bool>` | :ref:`get_avoidance_mask_value<class_NavigationAgent2D_method_get_avoidance_mask_value>`\ (\ mask_number\: :ref:`int<class_int>`\ ) |const| |
  99. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`PackedVector2Array<class_PackedVector2Array>` | :ref:`get_current_navigation_path<class_NavigationAgent2D_method_get_current_navigation_path>`\ (\ ) |const| |
  101. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`int<class_int>` | :ref:`get_current_navigation_path_index<class_NavigationAgent2D_method_get_current_navigation_path_index>`\ (\ ) |const| |
  103. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`NavigationPathQueryResult2D<class_NavigationPathQueryResult2D>` | :ref:`get_current_navigation_result<class_NavigationAgent2D_method_get_current_navigation_result>`\ (\ ) |const| |
  105. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`Vector2<class_Vector2>` | :ref:`get_final_position<class_NavigationAgent2D_method_get_final_position>`\ (\ ) |
  107. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`bool<class_bool>` | :ref:`get_navigation_layer_value<class_NavigationAgent2D_method_get_navigation_layer_value>`\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| |
  109. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`RID<class_RID>` | :ref:`get_navigation_map<class_NavigationAgent2D_method_get_navigation_map>`\ (\ ) |const| |
  111. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`Vector2<class_Vector2>` | :ref:`get_next_path_position<class_NavigationAgent2D_method_get_next_path_position>`\ (\ ) |
  113. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`float<class_float>` | :ref:`get_path_length<class_NavigationAgent2D_method_get_path_length>`\ (\ ) |const| |
  115. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | :ref:`RID<class_RID>` | :ref:`get_rid<class_NavigationAgent2D_method_get_rid>`\ (\ ) |const| |
  117. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`bool<class_bool>` | :ref:`is_navigation_finished<class_NavigationAgent2D_method_is_navigation_finished>`\ (\ ) |
  119. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`bool<class_bool>` | :ref:`is_target_reachable<class_NavigationAgent2D_method_is_target_reachable>`\ (\ ) |
  121. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`bool<class_bool>` | :ref:`is_target_reached<class_NavigationAgent2D_method_is_target_reached>`\ (\ ) |const| |
  123. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | |void| | :ref:`set_avoidance_layer_value<class_NavigationAgent2D_method_set_avoidance_layer_value>`\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) |
  125. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | |void| | :ref:`set_avoidance_mask_value<class_NavigationAgent2D_method_set_avoidance_mask_value>`\ (\ mask_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) |
  127. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | |void| | :ref:`set_navigation_layer_value<class_NavigationAgent2D_method_set_navigation_layer_value>`\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) |
  129. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | |void| | :ref:`set_navigation_map<class_NavigationAgent2D_method_set_navigation_map>`\ (\ navigation_map\: :ref:`RID<class_RID>`\ ) |
  131. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | |void| | :ref:`set_velocity_forced<class_NavigationAgent2D_method_set_velocity_forced>`\ (\ velocity\: :ref:`Vector2<class_Vector2>`\ ) |
  133. +-----------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. .. rst-class:: classref-section-separator
  135. ----
  136. .. rst-class:: classref-descriptions-group
  137. Signals
  138. -------
  139. .. _class_NavigationAgent2D_signal_link_reached:
  140. .. rst-class:: classref-signal
  141. **link_reached**\ (\ details\: :ref:`Dictionary<class_Dictionary>`\ ) :ref:`🔗<class_NavigationAgent2D_signal_link_reached>`
  142. Signals that the agent reached a navigation link. Emitted when the agent moves within :ref:`path_desired_distance<class_NavigationAgent2D_property_path_desired_distance>` of the next position of the path when that position is a navigation link.
  143. The details dictionary may contain the following keys depending on the value of :ref:`path_metadata_flags<class_NavigationAgent2D_property_path_metadata_flags>`:
  144. - ``position``: The start position of the link that was reached.
  145. - ``type``: Always :ref:`NavigationPathQueryResult2D.PATH_SEGMENT_TYPE_LINK<class_NavigationPathQueryResult2D_constant_PATH_SEGMENT_TYPE_LINK>`.
  146. - ``rid``: The :ref:`RID<class_RID>` of the link.
  147. - ``owner``: The object which manages the link (usually :ref:`NavigationLink2D<class_NavigationLink2D>`).
  148. - ``link_entry_position``: If ``owner`` is available and the owner is a :ref:`NavigationLink2D<class_NavigationLink2D>`, it will contain the global position of the link's point the agent is entering.
  149. - ``link_exit_position``: If ``owner`` is available and the owner is a :ref:`NavigationLink2D<class_NavigationLink2D>`, it will contain the global position of the link's point which the agent is exiting.
  150. .. rst-class:: classref-item-separator
  151. ----
  152. .. _class_NavigationAgent2D_signal_navigation_finished:
  153. .. rst-class:: classref-signal
  154. **navigation_finished**\ (\ ) :ref:`🔗<class_NavigationAgent2D_signal_navigation_finished>`
  155. Signals that the agent's navigation has finished. If the target is reachable, navigation ends when the target is reached. If the target is unreachable, navigation ends when the last waypoint of the path is reached. This signal is emitted only once per loaded path.
  156. This signal will be emitted just after :ref:`target_reached<class_NavigationAgent2D_signal_target_reached>` when the target is reachable.
  157. .. rst-class:: classref-item-separator
  158. ----
  159. .. _class_NavigationAgent2D_signal_path_changed:
  160. .. rst-class:: classref-signal
  161. **path_changed**\ (\ ) :ref:`🔗<class_NavigationAgent2D_signal_path_changed>`
  162. Emitted when the agent had to update the loaded path:
  163. - because path was previously empty.
  164. - because navigation map has changed.
  165. - because agent pushed further away from the current path segment than the :ref:`path_max_distance<class_NavigationAgent2D_property_path_max_distance>`.
  166. .. rst-class:: classref-item-separator
  167. ----
  168. .. _class_NavigationAgent2D_signal_target_reached:
  169. .. rst-class:: classref-signal
  170. **target_reached**\ (\ ) :ref:`🔗<class_NavigationAgent2D_signal_target_reached>`
  171. Signals that the agent reached the target, i.e. the agent moved within :ref:`target_desired_distance<class_NavigationAgent2D_property_target_desired_distance>` of the :ref:`target_position<class_NavigationAgent2D_property_target_position>`. This signal is emitted only once per loaded path.
  172. This signal will be emitted just before :ref:`navigation_finished<class_NavigationAgent2D_signal_navigation_finished>` when the target is reachable.
  173. It may not always be possible to reach the target but it should always be possible to reach the final position. See :ref:`get_final_position()<class_NavigationAgent2D_method_get_final_position>`.
  174. .. rst-class:: classref-item-separator
  175. ----
  176. .. _class_NavigationAgent2D_signal_velocity_computed:
  177. .. rst-class:: classref-signal
  178. **velocity_computed**\ (\ safe_velocity\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_NavigationAgent2D_signal_velocity_computed>`
  179. Notifies when the collision avoidance velocity is calculated. Emitted every update as long as :ref:`avoidance_enabled<class_NavigationAgent2D_property_avoidance_enabled>` is ``true`` and the agent has a navigation map.
  180. .. rst-class:: classref-item-separator
  181. ----
  182. .. _class_NavigationAgent2D_signal_waypoint_reached:
  183. .. rst-class:: classref-signal
  184. **waypoint_reached**\ (\ details\: :ref:`Dictionary<class_Dictionary>`\ ) :ref:`🔗<class_NavigationAgent2D_signal_waypoint_reached>`
  185. Signals that the agent reached a waypoint. Emitted when the agent moves within :ref:`path_desired_distance<class_NavigationAgent2D_property_path_desired_distance>` of the next position of the path.
  186. The details dictionary may contain the following keys depending on the value of :ref:`path_metadata_flags<class_NavigationAgent2D_property_path_metadata_flags>`:
  187. - ``position``: The position of the waypoint that was reached.
  188. - ``type``: The type of navigation primitive (region or link) that contains this waypoint.
  189. - ``rid``: The :ref:`RID<class_RID>` of the containing navigation primitive (region or link).
  190. - ``owner``: The object which manages the containing navigation primitive (region or link).
  191. .. rst-class:: classref-section-separator
  192. ----
  193. .. rst-class:: classref-descriptions-group
  194. Property Descriptions
  195. ---------------------
  196. .. _class_NavigationAgent2D_property_avoidance_enabled:
  197. .. rst-class:: classref-property
  198. :ref:`bool<class_bool>` **avoidance_enabled** = ``false`` :ref:`🔗<class_NavigationAgent2D_property_avoidance_enabled>`
  199. .. rst-class:: classref-property-setget
  200. - |void| **set_avoidance_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  201. - :ref:`bool<class_bool>` **get_avoidance_enabled**\ (\ )
  202. If ``true`` the agent is registered for an RVO avoidance callback on the :ref:`NavigationServer2D<class_NavigationServer2D>`. When :ref:`velocity<class_NavigationAgent2D_property_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.
  203. .. rst-class:: classref-item-separator
  204. ----
  205. .. _class_NavigationAgent2D_property_avoidance_layers:
  206. .. rst-class:: classref-property
  207. :ref:`int<class_int>` **avoidance_layers** = ``1`` :ref:`🔗<class_NavigationAgent2D_property_avoidance_layers>`
  208. .. rst-class:: classref-property-setget
  209. - |void| **set_avoidance_layers**\ (\ value\: :ref:`int<class_int>`\ )
  210. - :ref:`int<class_int>` **get_avoidance_layers**\ (\ )
  211. A bitfield determining the avoidance layers for this NavigationAgent. Other agents with a matching bit on the :ref:`avoidance_mask<class_NavigationAgent2D_property_avoidance_mask>` will avoid this agent.
  212. .. rst-class:: classref-item-separator
  213. ----
  214. .. _class_NavigationAgent2D_property_avoidance_mask:
  215. .. rst-class:: classref-property
  216. :ref:`int<class_int>` **avoidance_mask** = ``1`` :ref:`🔗<class_NavigationAgent2D_property_avoidance_mask>`
  217. .. rst-class:: classref-property-setget
  218. - |void| **set_avoidance_mask**\ (\ value\: :ref:`int<class_int>`\ )
  219. - :ref:`int<class_int>` **get_avoidance_mask**\ (\ )
  220. A bitfield determining what other avoidance agents and obstacles this NavigationAgent will avoid when a bit matches at least one of their :ref:`avoidance_layers<class_NavigationAgent2D_property_avoidance_layers>`.
  221. .. rst-class:: classref-item-separator
  222. ----
  223. .. _class_NavigationAgent2D_property_avoidance_priority:
  224. .. rst-class:: classref-property
  225. :ref:`float<class_float>` **avoidance_priority** = ``1.0`` :ref:`🔗<class_NavigationAgent2D_property_avoidance_priority>`
  226. .. rst-class:: classref-property-setget
  227. - |void| **set_avoidance_priority**\ (\ value\: :ref:`float<class_float>`\ )
  228. - :ref:`float<class_float>` **get_avoidance_priority**\ (\ )
  229. The agent does not adjust the velocity for other agents that would match the :ref:`avoidance_mask<class_NavigationAgent2D_property_avoidance_mask>` but have a lower :ref:`avoidance_priority<class_NavigationAgent2D_property_avoidance_priority>`. This in turn makes the other agents with lower priority adjust their velocities even more to avoid collision with this agent.
  230. .. rst-class:: classref-item-separator
  231. ----
  232. .. _class_NavigationAgent2D_property_debug_enabled:
  233. .. rst-class:: classref-property
  234. :ref:`bool<class_bool>` **debug_enabled** = ``false`` :ref:`🔗<class_NavigationAgent2D_property_debug_enabled>`
  235. .. rst-class:: classref-property-setget
  236. - |void| **set_debug_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  237. - :ref:`bool<class_bool>` **get_debug_enabled**\ (\ )
  238. If ``true`` shows debug visuals for this agent.
  239. .. rst-class:: classref-item-separator
  240. ----
  241. .. _class_NavigationAgent2D_property_debug_path_custom_color:
  242. .. rst-class:: classref-property
  243. :ref:`Color<class_Color>` **debug_path_custom_color** = ``Color(1, 1, 1, 1)`` :ref:`🔗<class_NavigationAgent2D_property_debug_path_custom_color>`
  244. .. rst-class:: classref-property-setget
  245. - |void| **set_debug_path_custom_color**\ (\ value\: :ref:`Color<class_Color>`\ )
  246. - :ref:`Color<class_Color>` **get_debug_path_custom_color**\ (\ )
  247. If :ref:`debug_use_custom<class_NavigationAgent2D_property_debug_use_custom>` is ``true`` uses this color for this agent instead of global color.
  248. .. rst-class:: classref-item-separator
  249. ----
  250. .. _class_NavigationAgent2D_property_debug_path_custom_line_width:
  251. .. rst-class:: classref-property
  252. :ref:`float<class_float>` **debug_path_custom_line_width** = ``-1.0`` :ref:`🔗<class_NavigationAgent2D_property_debug_path_custom_line_width>`
  253. .. rst-class:: classref-property-setget
  254. - |void| **set_debug_path_custom_line_width**\ (\ value\: :ref:`float<class_float>`\ )
  255. - :ref:`float<class_float>` **get_debug_path_custom_line_width**\ (\ )
  256. If :ref:`debug_use_custom<class_NavigationAgent2D_property_debug_use_custom>` is ``true`` uses this line width for rendering paths for this agent instead of global line width.
  257. .. rst-class:: classref-item-separator
  258. ----
  259. .. _class_NavigationAgent2D_property_debug_path_custom_point_size:
  260. .. rst-class:: classref-property
  261. :ref:`float<class_float>` **debug_path_custom_point_size** = ``4.0`` :ref:`🔗<class_NavigationAgent2D_property_debug_path_custom_point_size>`
  262. .. rst-class:: classref-property-setget
  263. - |void| **set_debug_path_custom_point_size**\ (\ value\: :ref:`float<class_float>`\ )
  264. - :ref:`float<class_float>` **get_debug_path_custom_point_size**\ (\ )
  265. If :ref:`debug_use_custom<class_NavigationAgent2D_property_debug_use_custom>` is ``true`` uses this rasterized point size for rendering path points for this agent instead of global point size.
  266. .. rst-class:: classref-item-separator
  267. ----
  268. .. _class_NavigationAgent2D_property_debug_use_custom:
  269. .. rst-class:: classref-property
  270. :ref:`bool<class_bool>` **debug_use_custom** = ``false`` :ref:`🔗<class_NavigationAgent2D_property_debug_use_custom>`
  271. .. rst-class:: classref-property-setget
  272. - |void| **set_debug_use_custom**\ (\ value\: :ref:`bool<class_bool>`\ )
  273. - :ref:`bool<class_bool>` **get_debug_use_custom**\ (\ )
  274. If ``true`` uses the defined :ref:`debug_path_custom_color<class_NavigationAgent2D_property_debug_path_custom_color>` for this agent instead of global color.
  275. .. rst-class:: classref-item-separator
  276. ----
  277. .. _class_NavigationAgent2D_property_max_neighbors:
  278. .. rst-class:: classref-property
  279. :ref:`int<class_int>` **max_neighbors** = ``10`` :ref:`🔗<class_NavigationAgent2D_property_max_neighbors>`
  280. .. rst-class:: classref-property-setget
  281. - |void| **set_max_neighbors**\ (\ value\: :ref:`int<class_int>`\ )
  282. - :ref:`int<class_int>` **get_max_neighbors**\ (\ )
  283. The maximum number of neighbors for the agent to consider.
  284. .. rst-class:: classref-item-separator
  285. ----
  286. .. _class_NavigationAgent2D_property_max_speed:
  287. .. rst-class:: classref-property
  288. :ref:`float<class_float>` **max_speed** = ``100.0`` :ref:`🔗<class_NavigationAgent2D_property_max_speed>`
  289. .. rst-class:: classref-property-setget
  290. - |void| **set_max_speed**\ (\ value\: :ref:`float<class_float>`\ )
  291. - :ref:`float<class_float>` **get_max_speed**\ (\ )
  292. The maximum speed that an agent can move.
  293. .. rst-class:: classref-item-separator
  294. ----
  295. .. _class_NavigationAgent2D_property_navigation_layers:
  296. .. rst-class:: classref-property
  297. :ref:`int<class_int>` **navigation_layers** = ``1`` :ref:`🔗<class_NavigationAgent2D_property_navigation_layers>`
  298. .. rst-class:: classref-property-setget
  299. - |void| **set_navigation_layers**\ (\ value\: :ref:`int<class_int>`\ )
  300. - :ref:`int<class_int>` **get_navigation_layers**\ (\ )
  301. A bitfield determining which navigation layers of navigation regions this agent will use to calculate a path. Changing it during runtime will clear the current navigation path and generate a new one, according to the new navigation layers.
  302. .. rst-class:: classref-item-separator
  303. ----
  304. .. _class_NavigationAgent2D_property_neighbor_distance:
  305. .. rst-class:: classref-property
  306. :ref:`float<class_float>` **neighbor_distance** = ``500.0`` :ref:`🔗<class_NavigationAgent2D_property_neighbor_distance>`
  307. .. rst-class:: classref-property-setget
  308. - |void| **set_neighbor_distance**\ (\ value\: :ref:`float<class_float>`\ )
  309. - :ref:`float<class_float>` **get_neighbor_distance**\ (\ )
  310. The distance to search for other agents.
  311. .. rst-class:: classref-item-separator
  312. ----
  313. .. _class_NavigationAgent2D_property_path_desired_distance:
  314. .. rst-class:: classref-property
  315. :ref:`float<class_float>` **path_desired_distance** = ``20.0`` :ref:`🔗<class_NavigationAgent2D_property_path_desired_distance>`
  316. .. rst-class:: classref-property-setget
  317. - |void| **set_path_desired_distance**\ (\ value\: :ref:`float<class_float>`\ )
  318. - :ref:`float<class_float>` **get_path_desired_distance**\ (\ )
  319. The distance threshold before a path point is considered to be reached. This allows agents to not have to hit a path point on the path exactly, but only to reach its general area. If this value is set too high, the NavigationAgent will skip points on the path, which can lead to it leaving the navigation mesh. If this value is set too low, the NavigationAgent will be stuck in a repath loop because it will constantly overshoot the distance to the next point on each physics frame update.
  320. .. rst-class:: classref-item-separator
  321. ----
  322. .. _class_NavigationAgent2D_property_path_max_distance:
  323. .. rst-class:: classref-property
  324. :ref:`float<class_float>` **path_max_distance** = ``100.0`` :ref:`🔗<class_NavigationAgent2D_property_path_max_distance>`
  325. .. rst-class:: classref-property-setget
  326. - |void| **set_path_max_distance**\ (\ value\: :ref:`float<class_float>`\ )
  327. - :ref:`float<class_float>` **get_path_max_distance**\ (\ )
  328. The maximum distance the agent is allowed away from the ideal path to the final position. This can happen due to trying to avoid collisions. When the maximum distance is exceeded, it recalculates the ideal path.
  329. .. rst-class:: classref-item-separator
  330. ----
  331. .. _class_NavigationAgent2D_property_path_metadata_flags:
  332. .. rst-class:: classref-property
  333. |bitfield|\[:ref:`PathMetadataFlags<enum_NavigationPathQueryParameters2D_PathMetadataFlags>`\] **path_metadata_flags** = ``7`` :ref:`🔗<class_NavigationAgent2D_property_path_metadata_flags>`
  334. .. rst-class:: classref-property-setget
  335. - |void| **set_path_metadata_flags**\ (\ value\: |bitfield|\[:ref:`PathMetadataFlags<enum_NavigationPathQueryParameters2D_PathMetadataFlags>`\]\ )
  336. - |bitfield|\[:ref:`PathMetadataFlags<enum_NavigationPathQueryParameters2D_PathMetadataFlags>`\] **get_path_metadata_flags**\ (\ )
  337. Additional information to return with the navigation path.
  338. .. rst-class:: classref-item-separator
  339. ----
  340. .. _class_NavigationAgent2D_property_path_postprocessing:
  341. .. rst-class:: classref-property
  342. :ref:`PathPostProcessing<enum_NavigationPathQueryParameters2D_PathPostProcessing>` **path_postprocessing** = ``0`` :ref:`🔗<class_NavigationAgent2D_property_path_postprocessing>`
  343. .. rst-class:: classref-property-setget
  344. - |void| **set_path_postprocessing**\ (\ value\: :ref:`PathPostProcessing<enum_NavigationPathQueryParameters2D_PathPostProcessing>`\ )
  345. - :ref:`PathPostProcessing<enum_NavigationPathQueryParameters2D_PathPostProcessing>` **get_path_postprocessing**\ (\ )
  346. The path postprocessing applied to the raw path corridor found by the :ref:`pathfinding_algorithm<class_NavigationAgent2D_property_pathfinding_algorithm>`.
  347. .. rst-class:: classref-item-separator
  348. ----
  349. .. _class_NavigationAgent2D_property_path_return_max_length:
  350. .. rst-class:: classref-property
  351. :ref:`float<class_float>` **path_return_max_length** = ``0.0`` :ref:`🔗<class_NavigationAgent2D_property_path_return_max_length>`
  352. .. rst-class:: classref-property-setget
  353. - |void| **set_path_return_max_length**\ (\ value\: :ref:`float<class_float>`\ )
  354. - :ref:`float<class_float>` **get_path_return_max_length**\ (\ )
  355. The maximum allowed length of the returned path in world units. A path will be clipped when going over this length.
  356. .. rst-class:: classref-item-separator
  357. ----
  358. .. _class_NavigationAgent2D_property_path_return_max_radius:
  359. .. rst-class:: classref-property
  360. :ref:`float<class_float>` **path_return_max_radius** = ``0.0`` :ref:`🔗<class_NavigationAgent2D_property_path_return_max_radius>`
  361. .. rst-class:: classref-property-setget
  362. - |void| **set_path_return_max_radius**\ (\ value\: :ref:`float<class_float>`\ )
  363. - :ref:`float<class_float>` **get_path_return_max_radius**\ (\ )
  364. The maximum allowed radius in world units that the returned path can be from the path start. The path will be clipped when going over this radius. Compared to :ref:`path_return_max_length<class_NavigationAgent2D_property_path_return_max_length>`, this allows the agent to go that much further, if they need to walk around a corner.
  365. \ **Note:** This will perform a sphere clip considering only the actual navigation mesh path points with the first path position being the sphere's center.
  366. .. rst-class:: classref-item-separator
  367. ----
  368. .. _class_NavigationAgent2D_property_path_search_max_distance:
  369. .. rst-class:: classref-property
  370. :ref:`float<class_float>` **path_search_max_distance** = ``0.0`` :ref:`🔗<class_NavigationAgent2D_property_path_search_max_distance>`
  371. .. rst-class:: classref-property-setget
  372. - |void| **set_path_search_max_distance**\ (\ value\: :ref:`float<class_float>`\ )
  373. - :ref:`float<class_float>` **get_path_search_max_distance**\ (\ )
  374. The maximum distance a searched polygon can be away from the start polygon before the pathfinding cancels the search for a path to the (possibly unreachable or very far away) target position polygon. In this case the pathfinding resets and builds a path from the start polygon to the polygon that was found closest to the target position so far. A value of ``0`` or below counts as unlimited. In case of unlimited the pathfinding will search all polygons connected with the start polygon until either the target position polygon is found or all available polygon search options are exhausted.
  375. .. rst-class:: classref-item-separator
  376. ----
  377. .. _class_NavigationAgent2D_property_path_search_max_polygons:
  378. .. rst-class:: classref-property
  379. :ref:`int<class_int>` **path_search_max_polygons** = ``4096`` :ref:`🔗<class_NavigationAgent2D_property_path_search_max_polygons>`
  380. .. rst-class:: classref-property-setget
  381. - |void| **set_path_search_max_polygons**\ (\ value\: :ref:`int<class_int>`\ )
  382. - :ref:`int<class_int>` **get_path_search_max_polygons**\ (\ )
  383. The maximum number of polygons that are searched before the pathfinding cancels the search for a path to the (possibly unreachable or very far away) target position polygon. In this case the pathfinding resets and builds a path from the start polygon to the polygon that was found closest to the target position so far. A value of ``0`` or below counts as unlimited. In case of unlimited the pathfinding will search all polygons connected with the start polygon until either the target position polygon is found or all available polygon search options are exhausted.
  384. .. rst-class:: classref-item-separator
  385. ----
  386. .. _class_NavigationAgent2D_property_pathfinding_algorithm:
  387. .. rst-class:: classref-property
  388. :ref:`PathfindingAlgorithm<enum_NavigationPathQueryParameters2D_PathfindingAlgorithm>` **pathfinding_algorithm** = ``0`` :ref:`🔗<class_NavigationAgent2D_property_pathfinding_algorithm>`
  389. .. rst-class:: classref-property-setget
  390. - |void| **set_pathfinding_algorithm**\ (\ value\: :ref:`PathfindingAlgorithm<enum_NavigationPathQueryParameters2D_PathfindingAlgorithm>`\ )
  391. - :ref:`PathfindingAlgorithm<enum_NavigationPathQueryParameters2D_PathfindingAlgorithm>` **get_pathfinding_algorithm**\ (\ )
  392. The pathfinding algorithm used in the path query.
  393. .. rst-class:: classref-item-separator
  394. ----
  395. .. _class_NavigationAgent2D_property_radius:
  396. .. rst-class:: classref-property
  397. :ref:`float<class_float>` **radius** = ``10.0`` :ref:`🔗<class_NavigationAgent2D_property_radius>`
  398. .. rst-class:: classref-property-setget
  399. - |void| **set_radius**\ (\ value\: :ref:`float<class_float>`\ )
  400. - :ref:`float<class_float>` **get_radius**\ (\ )
  401. 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>`).
  402. Does not affect normal pathfinding. To change an actor's pathfinding radius bake :ref:`NavigationPolygon<class_NavigationPolygon>` resources with a different :ref:`NavigationPolygon.agent_radius<class_NavigationPolygon_property_agent_radius>` property and use different navigation maps for each actor size.
  403. .. rst-class:: classref-item-separator
  404. ----
  405. .. _class_NavigationAgent2D_property_simplify_epsilon:
  406. .. rst-class:: classref-property
  407. :ref:`float<class_float>` **simplify_epsilon** = ``0.0`` :ref:`🔗<class_NavigationAgent2D_property_simplify_epsilon>`
  408. .. rst-class:: classref-property-setget
  409. - |void| **set_simplify_epsilon**\ (\ value\: :ref:`float<class_float>`\ )
  410. - :ref:`float<class_float>` **get_simplify_epsilon**\ (\ )
  411. The path simplification amount in worlds units.
  412. .. rst-class:: classref-item-separator
  413. ----
  414. .. _class_NavigationAgent2D_property_simplify_path:
  415. .. rst-class:: classref-property
  416. :ref:`bool<class_bool>` **simplify_path** = ``false`` :ref:`🔗<class_NavigationAgent2D_property_simplify_path>`
  417. .. rst-class:: classref-property-setget
  418. - |void| **set_simplify_path**\ (\ value\: :ref:`bool<class_bool>`\ )
  419. - :ref:`bool<class_bool>` **get_simplify_path**\ (\ )
  420. If ``true`` a simplified version of the path will be returned with less critical path points removed. The simplification amount is controlled by :ref:`simplify_epsilon<class_NavigationAgent2D_property_simplify_epsilon>`. The simplification uses a variant of Ramer-Douglas-Peucker algorithm for curve point decimation.
  421. Path simplification can be helpful to mitigate various path following issues that can arise with certain agent types and script behaviors. E.g. "steering" agents or avoidance in "open fields".
  422. .. rst-class:: classref-item-separator
  423. ----
  424. .. _class_NavigationAgent2D_property_target_desired_distance:
  425. .. rst-class:: classref-property
  426. :ref:`float<class_float>` **target_desired_distance** = ``10.0`` :ref:`🔗<class_NavigationAgent2D_property_target_desired_distance>`
  427. .. rst-class:: classref-property-setget
  428. - |void| **set_target_desired_distance**\ (\ value\: :ref:`float<class_float>`\ )
  429. - :ref:`float<class_float>` **get_target_desired_distance**\ (\ )
  430. The distance threshold before the target is considered to be reached. On reaching the target, :ref:`target_reached<class_NavigationAgent2D_signal_target_reached>` is emitted and navigation ends (see :ref:`is_navigation_finished()<class_NavigationAgent2D_method_is_navigation_finished>` and :ref:`navigation_finished<class_NavigationAgent2D_signal_navigation_finished>`).
  431. You can make navigation end early by setting this property to a value greater than :ref:`path_desired_distance<class_NavigationAgent2D_property_path_desired_distance>` (navigation will end before reaching the last waypoint).
  432. You can also make navigation end closer to the target than each individual path position by setting this property to a value lower than :ref:`path_desired_distance<class_NavigationAgent2D_property_path_desired_distance>` (navigation won't immediately end when reaching the last waypoint). However, if the value set is too low, the agent will be stuck in a repath loop because it will constantly overshoot the distance to the target on each physics frame update.
  433. .. rst-class:: classref-item-separator
  434. ----
  435. .. _class_NavigationAgent2D_property_target_position:
  436. .. rst-class:: classref-property
  437. :ref:`Vector2<class_Vector2>` **target_position** = ``Vector2(0, 0)`` :ref:`🔗<class_NavigationAgent2D_property_target_position>`
  438. .. rst-class:: classref-property-setget
  439. - |void| **set_target_position**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
  440. - :ref:`Vector2<class_Vector2>` **get_target_position**\ (\ )
  441. If set, a new navigation path from the current agent position to the :ref:`target_position<class_NavigationAgent2D_property_target_position>` is requested from the NavigationServer.
  442. .. rst-class:: classref-item-separator
  443. ----
  444. .. _class_NavigationAgent2D_property_time_horizon_agents:
  445. .. rst-class:: classref-property
  446. :ref:`float<class_float>` **time_horizon_agents** = ``1.0`` :ref:`🔗<class_NavigationAgent2D_property_time_horizon_agents>`
  447. .. rst-class:: classref-property-setget
  448. - |void| **set_time_horizon_agents**\ (\ value\: :ref:`float<class_float>`\ )
  449. - :ref:`float<class_float>` **get_time_horizon_agents**\ (\ )
  450. 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. A too high value will slow down agents movement considerably. Must be positive.
  451. .. rst-class:: classref-item-separator
  452. ----
  453. .. _class_NavigationAgent2D_property_time_horizon_obstacles:
  454. .. rst-class:: classref-property
  455. :ref:`float<class_float>` **time_horizon_obstacles** = ``0.0`` :ref:`🔗<class_NavigationAgent2D_property_time_horizon_obstacles>`
  456. .. rst-class:: classref-property-setget
  457. - |void| **set_time_horizon_obstacles**\ (\ value\: :ref:`float<class_float>`\ )
  458. - :ref:`float<class_float>` **get_time_horizon_obstacles**\ (\ )
  459. The minimal amount of time for which this agent's velocities, that are computed with the collision avoidance algorithm, are safe with respect to static avoidance obstacles. The larger the number, the sooner the agent will respond to static avoidance obstacles, but less freedom in choosing its velocities. A too high value will slow down agents movement considerably. Must be positive.
  460. .. rst-class:: classref-item-separator
  461. ----
  462. .. _class_NavigationAgent2D_property_velocity:
  463. .. rst-class:: classref-property
  464. :ref:`Vector2<class_Vector2>` **velocity** = ``Vector2(0, 0)`` :ref:`🔗<class_NavigationAgent2D_property_velocity>`
  465. .. rst-class:: classref-property-setget
  466. - |void| **set_velocity**\ (\ value\: :ref:`Vector2<class_Vector2>`\ )
  467. - :ref:`Vector2<class_Vector2>` **get_velocity**\ (\ )
  468. Sets the new wanted velocity for the agent. The avoidance simulation will try to fulfill this velocity if possible but will modify it to avoid collision with other agents and obstacles. When an agent is teleported to a new position, use :ref:`set_velocity_forced()<class_NavigationAgent2D_method_set_velocity_forced>` as well to reset the internal simulation velocity.
  469. .. rst-class:: classref-section-separator
  470. ----
  471. .. rst-class:: classref-descriptions-group
  472. Method Descriptions
  473. -------------------
  474. .. _class_NavigationAgent2D_method_distance_to_target:
  475. .. rst-class:: classref-method
  476. :ref:`float<class_float>` **distance_to_target**\ (\ ) |const| :ref:`🔗<class_NavigationAgent2D_method_distance_to_target>`
  477. Returns the distance to the target position, using the agent's global position. The user must set :ref:`target_position<class_NavigationAgent2D_property_target_position>` in order for this to be accurate.
  478. .. rst-class:: classref-item-separator
  479. ----
  480. .. _class_NavigationAgent2D_method_get_avoidance_layer_value:
  481. .. rst-class:: classref-method
  482. :ref:`bool<class_bool>` **get_avoidance_layer_value**\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_NavigationAgent2D_method_get_avoidance_layer_value>`
  483. Returns whether or not the specified layer of the :ref:`avoidance_layers<class_NavigationAgent2D_property_avoidance_layers>` bitmask is enabled, given a ``layer_number`` between 1 and 32.
  484. .. rst-class:: classref-item-separator
  485. ----
  486. .. _class_NavigationAgent2D_method_get_avoidance_mask_value:
  487. .. rst-class:: classref-method
  488. :ref:`bool<class_bool>` **get_avoidance_mask_value**\ (\ mask_number\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_NavigationAgent2D_method_get_avoidance_mask_value>`
  489. Returns whether or not the specified mask of the :ref:`avoidance_mask<class_NavigationAgent2D_property_avoidance_mask>` bitmask is enabled, given a ``mask_number`` between 1 and 32.
  490. .. rst-class:: classref-item-separator
  491. ----
  492. .. _class_NavigationAgent2D_method_get_current_navigation_path:
  493. .. rst-class:: classref-method
  494. :ref:`PackedVector2Array<class_PackedVector2Array>` **get_current_navigation_path**\ (\ ) |const| :ref:`🔗<class_NavigationAgent2D_method_get_current_navigation_path>`
  495. Returns this agent's current path from start to finish in global coordinates. The path only updates when the target position 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_path_position()<class_NavigationAgent2D_method_get_next_path_position>` once every physics frame to receive the next path point for the agents movement as this function also updates the internal path logic.
  496. .. rst-class:: classref-item-separator
  497. ----
  498. .. _class_NavigationAgent2D_method_get_current_navigation_path_index:
  499. .. rst-class:: classref-method
  500. :ref:`int<class_int>` **get_current_navigation_path_index**\ (\ ) |const| :ref:`🔗<class_NavigationAgent2D_method_get_current_navigation_path_index>`
  501. Returns which index the agent is currently on in the navigation path's :ref:`PackedVector2Array<class_PackedVector2Array>`.
  502. .. rst-class:: classref-item-separator
  503. ----
  504. .. _class_NavigationAgent2D_method_get_current_navigation_result:
  505. .. rst-class:: classref-method
  506. :ref:`NavigationPathQueryResult2D<class_NavigationPathQueryResult2D>` **get_current_navigation_result**\ (\ ) |const| :ref:`🔗<class_NavigationAgent2D_method_get_current_navigation_result>`
  507. Returns the path query result for the path the agent is currently following.
  508. .. rst-class:: classref-item-separator
  509. ----
  510. .. _class_NavigationAgent2D_method_get_final_position:
  511. .. rst-class:: classref-method
  512. :ref:`Vector2<class_Vector2>` **get_final_position**\ (\ ) :ref:`🔗<class_NavigationAgent2D_method_get_final_position>`
  513. Returns the reachable final position of the current navigation path in global coordinates. This position can change if the agent needs to update the navigation path which makes the agent emit the :ref:`path_changed<class_NavigationAgent2D_signal_path_changed>` signal.
  514. .. rst-class:: classref-item-separator
  515. ----
  516. .. _class_NavigationAgent2D_method_get_navigation_layer_value:
  517. .. rst-class:: classref-method
  518. :ref:`bool<class_bool>` **get_navigation_layer_value**\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_NavigationAgent2D_method_get_navigation_layer_value>`
  519. 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.
  520. .. rst-class:: classref-item-separator
  521. ----
  522. .. _class_NavigationAgent2D_method_get_navigation_map:
  523. .. rst-class:: classref-method
  524. :ref:`RID<class_RID>` **get_navigation_map**\ (\ ) |const| :ref:`🔗<class_NavigationAgent2D_method_get_navigation_map>`
  525. 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.
  526. .. rst-class:: classref-item-separator
  527. ----
  528. .. _class_NavigationAgent2D_method_get_next_path_position:
  529. .. rst-class:: classref-method
  530. :ref:`Vector2<class_Vector2>` **get_next_path_position**\ (\ ) :ref:`🔗<class_NavigationAgent2D_method_get_next_path_position>`
  531. Returns the next position 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.
  532. .. rst-class:: classref-item-separator
  533. ----
  534. .. _class_NavigationAgent2D_method_get_path_length:
  535. .. rst-class:: classref-method
  536. :ref:`float<class_float>` **get_path_length**\ (\ ) |const| :ref:`🔗<class_NavigationAgent2D_method_get_path_length>`
  537. Returns the length of the currently calculated path. The returned value is ``0.0``, if the path is still calculating or no calculation has been requested yet.
  538. .. rst-class:: classref-item-separator
  539. ----
  540. .. _class_NavigationAgent2D_method_get_rid:
  541. .. rst-class:: classref-method
  542. :ref:`RID<class_RID>` **get_rid**\ (\ ) |const| :ref:`🔗<class_NavigationAgent2D_method_get_rid>`
  543. Returns the :ref:`RID<class_RID>` of this agent on the :ref:`NavigationServer2D<class_NavigationServer2D>`.
  544. .. rst-class:: classref-item-separator
  545. ----
  546. .. _class_NavigationAgent2D_method_is_navigation_finished:
  547. .. rst-class:: classref-method
  548. :ref:`bool<class_bool>` **is_navigation_finished**\ (\ ) :ref:`🔗<class_NavigationAgent2D_method_is_navigation_finished>`
  549. Returns ``true`` if the agent's navigation has finished. If the target is reachable, navigation ends when the target is reached. If the target is unreachable, navigation ends when the last waypoint of the path is reached.
  550. \ **Note:** While ``true`` prefer to stop calling update functions like :ref:`get_next_path_position()<class_NavigationAgent2D_method_get_next_path_position>`. This avoids jittering the standing agent due to calling repeated path updates.
  551. .. rst-class:: classref-item-separator
  552. ----
  553. .. _class_NavigationAgent2D_method_is_target_reachable:
  554. .. rst-class:: classref-method
  555. :ref:`bool<class_bool>` **is_target_reachable**\ (\ ) :ref:`🔗<class_NavigationAgent2D_method_is_target_reachable>`
  556. Returns ``true`` if :ref:`get_final_position()<class_NavigationAgent2D_method_get_final_position>` is within :ref:`target_desired_distance<class_NavigationAgent2D_property_target_desired_distance>` of the :ref:`target_position<class_NavigationAgent2D_property_target_position>`.
  557. .. rst-class:: classref-item-separator
  558. ----
  559. .. _class_NavigationAgent2D_method_is_target_reached:
  560. .. rst-class:: classref-method
  561. :ref:`bool<class_bool>` **is_target_reached**\ (\ ) |const| :ref:`🔗<class_NavigationAgent2D_method_is_target_reached>`
  562. Returns ``true`` if the agent reached the target, i.e. the agent moved within :ref:`target_desired_distance<class_NavigationAgent2D_property_target_desired_distance>` of the :ref:`target_position<class_NavigationAgent2D_property_target_position>`. It may not always be possible to reach the target but it should always be possible to reach the final position. See :ref:`get_final_position()<class_NavigationAgent2D_method_get_final_position>`.
  563. .. rst-class:: classref-item-separator
  564. ----
  565. .. _class_NavigationAgent2D_method_set_avoidance_layer_value:
  566. .. rst-class:: classref-method
  567. |void| **set_avoidance_layer_value**\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_NavigationAgent2D_method_set_avoidance_layer_value>`
  568. Based on ``value``, enables or disables the specified layer in the :ref:`avoidance_layers<class_NavigationAgent2D_property_avoidance_layers>` bitmask, given a ``layer_number`` between 1 and 32.
  569. .. rst-class:: classref-item-separator
  570. ----
  571. .. _class_NavigationAgent2D_method_set_avoidance_mask_value:
  572. .. rst-class:: classref-method
  573. |void| **set_avoidance_mask_value**\ (\ mask_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_NavigationAgent2D_method_set_avoidance_mask_value>`
  574. Based on ``value``, enables or disables the specified mask in the :ref:`avoidance_mask<class_NavigationAgent2D_property_avoidance_mask>` bitmask, given a ``mask_number`` between 1 and 32.
  575. .. rst-class:: classref-item-separator
  576. ----
  577. .. _class_NavigationAgent2D_method_set_navigation_layer_value:
  578. .. rst-class:: classref-method
  579. |void| **set_navigation_layer_value**\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_NavigationAgent2D_method_set_navigation_layer_value>`
  580. 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.
  581. .. rst-class:: classref-item-separator
  582. ----
  583. .. _class_NavigationAgent2D_method_set_navigation_map:
  584. .. rst-class:: classref-method
  585. |void| **set_navigation_map**\ (\ navigation_map\: :ref:`RID<class_RID>`\ ) :ref:`🔗<class_NavigationAgent2D_method_set_navigation_map>`
  586. Sets the :ref:`RID<class_RID>` of the navigation map this NavigationAgent node should use and also updates the ``agent`` on the NavigationServer.
  587. .. rst-class:: classref-item-separator
  588. ----
  589. .. _class_NavigationAgent2D_method_set_velocity_forced:
  590. .. rst-class:: classref-method
  591. |void| **set_velocity_forced**\ (\ velocity\: :ref:`Vector2<class_Vector2>`\ ) :ref:`🔗<class_NavigationAgent2D_method_set_velocity_forced>`
  592. Replaces the internal velocity in the collision avoidance simulation with ``velocity``. When an agent is teleported to a new position this function should be used in the same frame. If called frequently this function can get agents stuck.
  593. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  594. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  595. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  596. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  597. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  598. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  599. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  600. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  601. .. |void| replace:: :abbr:`void (No return value.)`