1 Star 1 Fork 0

天天编程/godot-docs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
class_navigationagent.rst 17.25 KB
一键复制 编辑 原始数据 按行查看 历史
github_url: hide

NavigationAgent

Inherits: :ref:`Node<class_Node>` < :ref:`Object<class_Object>`

3D Agent used in navigation for collision avoidance.

Description

3D 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. This can be done by having the agent as a child of a :ref:`Navigation<class_Navigation>` node, or using :ref:`set_navigation<class_NavigationAgent_method_set_navigation>`. NavigationAgent is physics safe.

Properties

:ref:`float<class_float>` :ref:`agent_height_offset<class_NavigationAgent_property_agent_height_offset>` 0.0
:ref:`bool<class_bool>` :ref:`ignore_y<class_NavigationAgent_property_ignore_y>` true
:ref:`int<class_int>` :ref:`max_neighbors<class_NavigationAgent_property_max_neighbors>` 10
:ref:`float<class_float>` :ref:`max_speed<class_NavigationAgent_property_max_speed>` 10.0
:ref:`float<class_float>` :ref:`neighbor_dist<class_NavigationAgent_property_neighbor_dist>` 50.0
:ref:`float<class_float>` :ref:`path_max_distance<class_NavigationAgent_property_path_max_distance>` 3.0
:ref:`float<class_float>` :ref:`radius<class_NavigationAgent_property_radius>` 1.0
:ref:`float<class_float>` :ref:`target_desired_distance<class_NavigationAgent_property_target_desired_distance>` 1.0
:ref:`float<class_float>` :ref:`time_horizon<class_NavigationAgent_property_time_horizon>` 5.0

Methods

:ref:`float<class_float>` :ref:`distance_to_target<class_NavigationAgent_method_distance_to_target>` ( ) const
:ref:`Vector3<class_Vector3>` :ref:`get_final_location<class_NavigationAgent_method_get_final_location>` ( )
:ref:`PackedVector3Array<class_PackedVector3Array>` :ref:`get_nav_path<class_NavigationAgent_method_get_nav_path>` ( ) const
:ref:`int<class_int>` :ref:`get_nav_path_index<class_NavigationAgent_method_get_nav_path_index>` ( ) const
:ref:`Node<class_Node>` :ref:`get_navigation<class_NavigationAgent_method_get_navigation>` ( ) const
:ref:`Vector3<class_Vector3>` :ref:`get_next_location<class_NavigationAgent_method_get_next_location>` ( )
:ref:`Vector3<class_Vector3>` :ref:`get_target_location<class_NavigationAgent_method_get_target_location>` ( ) const
:ref:`bool<class_bool>` :ref:`is_navigation_finished<class_NavigationAgent_method_is_navigation_finished>` ( )
:ref:`bool<class_bool>` :ref:`is_target_reachable<class_NavigationAgent_method_is_target_reachable>` ( )
:ref:`bool<class_bool>` :ref:`is_target_reached<class_NavigationAgent_method_is_target_reached>` ( ) const
void :ref:`set_navigation<class_NavigationAgent_method_set_navigation>` ( :ref:`Node<class_Node>` navigation )
void :ref:`set_target_location<class_NavigationAgent_method_set_target_location>` ( :ref:`Vector3<class_Vector3>` location )
void :ref:`set_velocity<class_NavigationAgent_method_set_velocity>` ( :ref:`Vector3<class_Vector3>` velocity )

Signals

  • navigation_finished ( )

Notifies when the final location is reached.


  • path_changed ( )

Notifies when the navigation path changes.


  • target_reached ( )

Notifies when the player defined target, set with :ref:`set_target_location<class_NavigationAgent_method_set_target_location>`, is reached.


Notifies when the collision avoidance velocity is calculated. Emitted by :ref:`set_velocity<class_NavigationAgent_method_set_velocity>`.

Property Descriptions

Default 0.0
Setter set_agent_height_offset(value)
Getter get_agent_height_offset()

The agent height offset to match the navigation mesh height.


Default true
Setter set_ignore_y(value)
Getter get_ignore_y()

Ignores collisions on the Y axis. Must be true to move on a horizontal plane.


Default 10
Setter set_max_neighbors(value)
Getter get_max_neighbors()

The maximum number of neighbors for the agent to consider.


Default 10.0
Setter set_max_speed(value)
Getter get_max_speed()

The maximum speed that an agent can move.


Default 50.0
Setter set_neighbor_dist(value)
Getter get_neighbor_dist()

The distance to search for other agents.


Default 3.0
Setter set_path_max_distance(value)
Getter get_path_max_distance()

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.


Default 1.0
Setter set_radius(value)
Getter get_radius()

The radius of the agent.


Default 1.0
Setter set_target_desired_distance(value)
Getter get_target_desired_distance()

The distance threshold before a target is considered to be reached. This will allow an agent to not have to hit a point on the path exactly, but in the area.


Default 5.0
Setter set_time_horizon(value)
Getter get_time_horizon()

The minimal amount of time for which this agent's velocities, that are computed with the collision avoidance algorithim, 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.

Method Descriptions

Returns the distance to the target location, using the agent's global position. The user must set the target location with :ref:`set_target_location<class_NavigationAgent_method_set_target_location>` in order for this to be accurate.


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.


Returns the path from start to finish in global coordinates.


Returns which index the agent is currently on in the navigation path's :ref:`PackedVector3Array<class_PackedVector3Array>`.


Returns the :ref:`Navigation<class_Navigation>` node that the agent is using for its navigation system.


Returns a :ref:`Vector3<class_Vector3>` 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 origin of the agent's parent.


Returns the user defined :ref:`Vector3<class_Vector3>` after setting the target location.


Returns true if the navigation path's final location has been reached.


Returns true if the target location is reachable. The target location is set using :ref:`set_target_location<class_NavigationAgent_method_set_target_location>`.


Returns true if the target location is reached. The target location is set using :ref:`set_target_location<class_NavigationAgent_method_set_target_location>`. 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_NavigationAgent_method_get_final_location>`.


Sets the :ref:`Navigation<class_Navigation>` node used by the agent. Useful when you don't want to make the agent a child of a :ref:`Navigation<class_Navigation>` node.


Sets the user desired final location. This will clear the current navigation path.


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_NavigationAgent_signal_velocity_computed>` signal.

Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ttcode-net/godot-docs.git
git@gitee.com:ttcode-net/godot-docs.git
ttcode-net
godot-docs
godot-docs
master

搜索帮助