Navigation

Inherits: Spatial < Node < Object

Mesh-based navigation and pathfinding node.

Description

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 navmesh_add. In addition to basic pathfinding, this class also assists with aligning navigation agents with the meshes they are navigating on.

Tutorials

Properties

Vector3up_vectorVector3( 0, 1, 0 )

Methods

Vector3get_closest_point ( Vector3 to_point )
Vector3get_closest_point_normal ( Vector3 to_point )
Objectget_closest_point_owner ( Vector3 to_point )
Vector3get_closest_point_to_segment ( Vector3 start, Vector3 end, bool use_collision=false )
PoolVector3Arrayget_simple_path ( Vector3 start, Vector3 end, bool optimize=true )
intnavmesh_add ( NavigationMesh mesh, Transform xform, Object owner=null )
voidnavmesh_remove ( int id )
voidnavmesh_set_transform ( int id, Transform xform )

Property Descriptions

DefaultVector3( 0, 1, 0 )
Setterset_up_vector(value)
Getterget_up_vector()

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

Method Descriptions

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


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.


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 navmesh_add, returns the owner that was given (or null if the owner parameter was omitted).


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.


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 (radius, height, etc.) are considered in the path calculation, otherwise they are ignored.


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


  • void navmesh_remove ( int id )

Removes the NavigationMesh with the given ID.


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