Struct NavigationPolygon

A node that has methods to draw outlines or use indices of vertices to create navigation polygons.

struct NavigationPolygon ;

There are two ways to create polygons. Either by using the addOutline method, or using the addPolygon method. Using addOutline:

var polygon = NavigationPolygon.new() var outline = PoolVector2Array(Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)) polygon.add_outline(outline) polygon.make_polygons_from_outlines() $NavigationPolygonInstance.navpoly = polygon

Using addPolygon and indices of the vertices array.

var polygon = NavigationPolygon.new() var vertices = PoolVector2Array(Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)) polygon.set_vertices(vertices) var indices = PoolIntArray(0, 3, 1) polygon.add_polygon(indices) $NavigationPolygonInstance.navpoly = polygon

Properties

NameTypeDescription
outlines[get, set] Array
polygons[get, set] Array
vertices[get, set] PoolArray!(godot.core.vector2.Vector2)

Methods

NameDescription
_getOutlines
_getPolygons
_setOutlines
_setPolygons
addOutline Appends a PoolVector2Array that contains the vertices of an outline to the internal array that contains all the outlines. You have to call makePolygonsFromOutlines in order for this array to be converted to polygons that the engine will use.
addOutlineAtIndex Adds a PoolVector2Array that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position. You have to call makePolygonsFromOutlines in order for this array to be converted to polygons that the engine will use.
addPolygon Adds a polygon using the indices of the vertices you get when calling getVertices.
clearOutlines Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them.
clearPolygons Clears the array of polygons, but it doesn't clear the array of outlines and vertices.
getOutline Returns a PoolVector2Array containing the vertices of an outline that was created in the editor or by script.
getOutlineCount Returns the number of outlines that were created in the editor or by script.
getPolygon Returns a PoolIntArray containing the indices of the vertices of a created polygon.
getPolygonCount Returns the count of all polygons.
getVertices Returns a PoolVector2Array containing all the vertices being used to create the polygons.
makePolygonsFromOutlines Creates polygons from the outlines added in the editor or by script.
removeOutline Removes an outline created in the editor or by script. You have to call makePolygonsFromOutlines for the polygons to update.
setOutline Changes an outline created in the editor or by script. You have to call makePolygonsFromOutlines for the polygons to update.
setVertices Sets the vertices that can be then indexed to create polygons with the addPolygon method.