A collection of NavigationMesh resources and methods used for pathfinding.
    public class Navigation : Spatial

The Navigation node is used for basic or advanced navigation. By default it will automatically collect all child NavigationMesh resources, but they can also be added on the fly through scripting. It can be used for generating a simple path between two points or it can be used to ensure that a navigation agent is angled perfectly to the terrain it is navigating.

Inheritance Chain

Constructors

    public Navigation()

Properties

    public Vector3 UpVector { get; set; }

Defines which direction is up. The default defines 0,1,0 as up which is the world up direction. To make this a ceiling use 0,-1,0 to define down as up.

Methods

    public Vector3 GetClosestPoint(Vector3 toPoint)

Returns the closest navigation point to the point passed.

    public Vector3 GetClosestPointNormal(Vector3 toPoint)

Returns the surface normal of the navigation mesh at the point passed. For instance, if the point passed was at a 45 degree slope it would return something like (0.5,0.5,0). This is useful for rotating a navigation agent in accordance with the NavigationMesh.

    public Object GetClosestPointOwner(Vector3 toPoint)

Returns the nearest NavigationMeshInstance to the point passed.

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

Returns the nearest point to the line segment passed. The third optional parameter takes collisions into account.

    public Vector3[] GetSimplePath(Vector3 start, Vector3 end, bool optimize = true)

Returns a path of points as a PoolVector3Array. If optimize is false the NavigationMesh agent properties will be taken into account, otherwise it will return the nearest path and ignore agent radius, height, etc.

    public Vector3 GetUpVector()

Getter for UpVector

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

Adds a NavigationMesh to the list of NavigationMesh’s in this node. Returns an id. Its position, rotation and scale are associated with the Transform passed. The Node (or Object) that owns this node is an optional parameter.

    public void NavmeshRemove(int id)

Removes a NavigationMesh from the list of NavigationMesh’s in this node.

    public void NavmeshSetTransform(int id, Transform xform)

Associates a NavigationMesh’s id with a Transform. Its position, rotation and scale are based on the Transform passed.

    public void SetUpVector(Vector3 up)

Setter for UpVector

Tags: