Mesh-based navigation and pathfinding node.
    public class Navigation : Spatial

Provides navigation and pathfinding within a collection of NavigationMeshes. By default these will be automatically collected from child NavigationMeshInstance nodes, but they can also be added on the fly with NavmeshAdd(Godot.NavigationMesh, Godot.Transform, Godot.Object). In addition to basic pathfinding, this class also assists with aligning navigation agents with the meshes they are navigating on.

Inheritance Chain


    public Navigation()


    public Vector3 UpVector { get; set; }

Defines which direction is up. By default this is (0, 1, 0), which is the world up direction.


    public Vector3 GetClosestPoint(Vector3 toPoint)

Returns the navigation point closest to the point given. Points are in local coordinate space.

    public Vector3 GetClosestPointNormal(Vector3 toPoint)

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.

    public Object GetClosestPointOwner(Vector3 toPoint)

Returns the owner of the NavigationMesh which contains the navigation point closest to the point given. This is usually a NavigationMeshInstance. For meshes added via NavmeshAdd(Godot.NavigationMesh, Godot.Transform, Godot.Object), returns the owner that was given (or null if the owner parameter was omitted).

    public Vector3 GetClosestPointToSegment(Vector3 start, Vector3 end, bool useCollision = false)

Returns the navigation point closest to the given line segment. When enabling useCollision, 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.

    public Vector3[] GetSimplePath(Vector3 start, Vector3 end, 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 NavigationMesh (raidus, height, etc.) are considered in the path calculation, otherwise they are ignored.

    public Vector3 GetUpVector()

Getter for UpVector

    public int NavmeshAdd(NavigationMesh mesh, Transform xform, Object owner = null)

Adds a NavigationMesh. Returns an ID for use with NavmeshRemove(int) or NavmeshSetTransform(int, Godot.Transform). If given, a Transform2D is applied to the polygon. The optional owner is used as return value for GetClosestPointOwner(Godot.Vector3).

    public void NavmeshRemove(int id)

Removes the NavigationMesh with the given ID.

    public void NavmeshSetTransform(int id, Transform xform)

Sets the transform applied to the NavigationMesh with the given ID.

    public void SetUpVector(Vector3 up)

Setter for UpVector