NavigationPolygon

Inherits: Resource < Reference < Object A node that has methods to draw outlines or use indices of vertices to create navigation polygons.

Description

add_outline method, or using the add_polygon method. add_outline:

  1. 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

add_polygon and indices of the vertices array.

  1. 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, 1, 2, 3])polygon.add_polygon(indices)$NavigationPolygonInstance.navpoly = polygon

Tutorials

  • 2D Navigation Demo

    Methods

    Method Descriptions

  • add_outline ( PoolVector2Array outline ) PoolVector2Array that contains the vertices of an outline to the internal array that contains all the outlines. You have to call make_polygons_from_outlines in order for this array to be converted to polygons that the engine will use.

  • add_outline_at_index ( PoolVector2Array outline, int index ) 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 make_polygons_from_outlines in order for this array to be converted to polygons that the engine will use.

  • add_polygon ( PoolIntArray polygon ) get_vertices.

  • clear_outlines ( ) Clears the array of the outlines, but it doesn’t clear the vertices and the polygons that were created by them.

  • clear_polygons ( ) Clears the array of polygons, but it doesn’t clear the array of outlines and vertices.

  • NavigationMesh get_mesh ( ) NavigationMesh resulting from this navigation polygon. This navmesh can be used to update the navmesh of a region with the NavigationServer.region_set_navmesh API directly (as 2D uses the 3D server behind the scene).

  • PoolVector2Array get_outline ( int idx ) const PoolVector2Array containing the vertices of an outline that was created in the editor or by script.

  • int get_outline_count ( ) const Returns the number of outlines that were created in the editor or by script.

  • PoolIntArray get_polygon ( int idx ) PoolIntArray containing the indices of the vertices of a created polygon.

  • int get_polygon_count ( ) const Returns the count of all polygons.

  • PoolVector2Array get_vertices ( ) const PoolVector2Array containing all the vertices being used to create the polygons.

  • make_polygons_from_outlines ( ) Creates polygons from the outlines added in the editor or by script.

  • remove_outline ( int idx ) make_polygons_from_outlines for the polygons to update.

  • set_outline ( int idx, PoolVector2Array outline ) make_polygons_from_outlines for the polygons to update.

  • set_vertices ( PoolVector2Array vertices ) add_polygon method.