2D navigation and pathfinding node.
    public class Navigation2D : Node2D

Navigation2D provides navigation and pathfinding within a 2D area, specified as a collection of NavigationPolygon resources. By default these are automatically collected from child NavigationPolygonInstance nodes, but they can also be added on the fly with NavpolyAdd(Godot.NavigationPolygon, Godot.Transform2D, Godot.Object).

Inheritance Chain


    public Navigation2D()


    public Vector2 GetClosestPoint(Vector2 toPoint)

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

    public Object GetClosestPointOwner(Vector2 toPoint)

Returns the owner of the NavigationPolygon which contains the navigation point closest to the point given. This is usually a NavigtionPolygonInstance. For polygons added via NavpolyAdd(Godot.NavigationPolygon, Godot.Transform2D, Godot.Object), returns the owner that was given (or null if the owner parameter was omitted).

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

Returns the path between two given points. Points are in local coordinate space. If optimize is true (the default), the path is smoothed by merging path segments where possible.

    public int NavpolyAdd(NavigationPolygon mesh, Transform2D xform, Object owner = null)

Adds a NavigationPolygon. Returns an ID for use with NavpolyRemove(int) or NavpolySetTransform(int, Godot.Transform2D). If given, a Transform2D is applied to the polygon. The optional owner is used as return value for GetClosestPointOwner(Godot.Vector2).

    public void NavpolyRemove(int id)

Removes the NavigationPolygon with the given ID.

    public void NavpolySetTransform(int id, Transform2D xform)

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