:github_url: hide .. Generated automatically by doc/tools/make_rst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the Navigation.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_Navigation: Navigation ========== **Inherits:** :ref:`Spatial` **<** :ref:`Node` **<** :ref:`Object` Mesh-based navigation and pathfinding node. Description ----------- Provides navigation and pathfinding within a collection of :ref:`NavigationMesh`\ es. By default, these will be automatically collected from child :ref:`NavigationMeshInstance` nodes, but they can also be added on the fly with :ref:`navmesh_add`. In addition to basic pathfinding, this class also assists with aligning navigation agents with the meshes they are navigating on. **Note:** The current navigation system has many known issues and will not always return optimal paths as expected. These issues will be fixed in Godot 4.0. Tutorials --------- - `3D Navmesh Demo `__ Properties ---------- +-------------------------------+-------------------------------------------------------+------------------------+ | :ref:`Vector3` | :ref:`up_vector` | ``Vector3( 0, 1, 0 )`` | +-------------------------------+-------------------------------------------------------+------------------------+ Methods ------- +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector3` | :ref:`get_closest_point` **(** :ref:`Vector3` to_point **)** | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector3` | :ref:`get_closest_point_normal` **(** :ref:`Vector3` to_point **)** | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Object` | :ref:`get_closest_point_owner` **(** :ref:`Vector3` to_point **)** | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector3` | :ref:`get_closest_point_to_segment` **(** :ref:`Vector3` start, :ref:`Vector3` end, :ref:`bool` use_collision=false **)** | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PoolVector3Array` | :ref:`get_simple_path` **(** :ref:`Vector3` start, :ref:`Vector3` end, :ref:`bool` optimize=true **)** | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`navmesh_add` **(** :ref:`NavigationMesh` mesh, :ref:`Transform` xform, :ref:`Object` owner=null **)** | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`navmesh_remove` **(** :ref:`int` id **)** | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`navmesh_set_transform` **(** :ref:`int` id, :ref:`Transform` xform **)** | +-------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Property Descriptions --------------------- .. _class_Navigation_property_up_vector: - :ref:`Vector3` **up_vector** +-----------+------------------------+ | *Default* | ``Vector3( 0, 1, 0 )`` | +-----------+------------------------+ | *Setter* | set_up_vector(value) | +-----------+------------------------+ | *Getter* | get_up_vector() | +-----------+------------------------+ Defines which direction is up. By default, this is ``(0, 1, 0)``, which is the world's "up" direction. Method Descriptions ------------------- .. _class_Navigation_method_get_closest_point: - :ref:`Vector3` **get_closest_point** **(** :ref:`Vector3` to_point **)** Returns the navigation point closest to the point given. Points are in local coordinate space. ---- .. _class_Navigation_method_get_closest_point_normal: - :ref:`Vector3` **get_closest_point_normal** **(** :ref:`Vector3` to_point **)** Returns the surface normal at the navigation point closest to the point given. Useful for rotating a navigation agent according to the navigation mesh it moves on. ---- .. _class_Navigation_method_get_closest_point_owner: - :ref:`Object` **get_closest_point_owner** **(** :ref:`Vector3` to_point **)** Returns the owner of the :ref:`NavigationMesh` which contains the navigation point closest to the point given. This is usually a :ref:`NavigationMeshInstance`. For meshes added via :ref:`navmesh_add`, returns the owner that was given (or ``null`` if the ``owner`` parameter was omitted). ---- .. _class_Navigation_method_get_closest_point_to_segment: - :ref:`Vector3` **get_closest_point_to_segment** **(** :ref:`Vector3` start, :ref:`Vector3` end, :ref:`bool` use_collision=false **)** Returns the navigation point closest to the given line segment. When enabling ``use_collision``, only considers intersection points between segment and navigation meshes. If multiple intersection points are found, the one closest to the segment start point is returned. ---- .. _class_Navigation_method_get_simple_path: - :ref:`PoolVector3Array` **get_simple_path** **(** :ref:`Vector3` start, :ref:`Vector3` end, :ref:`bool` optimize=true **)** Returns the path between two given points. Points are in local coordinate space. If ``optimize`` is ``true`` (the default), the agent properties associated with each :ref:`NavigationMesh` (radius, height, etc.) are considered in the path calculation, otherwise they are ignored. **Note:** This method has known issues and will often return non-optimal paths. These issues will be fixed in Godot 4.0. ---- .. _class_Navigation_method_navmesh_add: - :ref:`int` **navmesh_add** **(** :ref:`NavigationMesh` mesh, :ref:`Transform` xform, :ref:`Object` owner=null **)** Adds a :ref:`NavigationMesh`. Returns an ID for use with :ref:`navmesh_remove` or :ref:`navmesh_set_transform`. If given, a :ref:`Transform2D` is applied to the polygon. The optional ``owner`` is used as return value for :ref:`get_closest_point_owner`. ---- .. _class_Navigation_method_navmesh_remove: - void **navmesh_remove** **(** :ref:`int` id **)** Removes the :ref:`NavigationMesh` with the given ID. ---- .. _class_Navigation_method_navmesh_set_transform: - void **navmesh_set_transform** **(** :ref:`int` id, :ref:`Transform` xform **)** Sets the transform applied to the :ref:`NavigationMesh` with the given ID. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`