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).
public Vector2 GetClosestPoint(Vector2 toPoint)
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 NavigationPolygonInstance. For polygons added via NavpolyAdd(Godot.NavigationPolygon, Godot.Transform2D, Godot.Object), returns the owner that was given (or
ownerparameter was omitted).
public Vector2 GetSimplePath(Vector2 start, Vector2 end, bool optimize = true)
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
owneris 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.