Navigation

    Mesh-based navigation and pathfinding node.

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

    Tutorials

    Methods

    • up_vector

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

    Method Descriptions

    • Vector3 get_closest_point ( 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.


    • Object get_closest_point_owner ( to_point )

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


    • get_closest_point_to_segment ( Vector3 start, end, 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.


    • get_simple_path ( Vector3 start, end, bool optimize=true )

    Adds a . Returns an ID for use with navmesh_remove or . If given, a Transform2D is applied to the polygon. The optional owner is used as return value for .


    Removes the NavigationMesh with the given ID.


    • void navmesh_set_transform ( id, Transform xform )

    Sets the transform applied to the with the given ID.