NavigationPolygon

package
v0.0.0-...-2b43b64 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package NavigationPolygon provides methods for working with NavigationPolygon object instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsNavigationPolygon() Instance
}

type Instance

type Instance [1]gdclass.NavigationPolygon

A navigation mesh can be created either by baking it with the help of the [NavigationServer2D], or by adding vertices and convex polygon indices arrays manually. To bake a navigation mesh at least one outline needs to be added that defines the outer bounds of the baked area. [codeblocks] [gdscript] var new_navigation_mesh = NavigationPolygon.new() var bounding_outline = PackedVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)]) new_navigation_mesh.add_outline(bounding_outline) NavigationServer2D.bake_from_source_geometry_data(new_navigation_mesh, NavigationMeshSourceGeometryData2D.new()); $NavigationRegion2D.navigation_polygon = new_navigation_mesh [/gdscript] [csharp] var newNavigationMesh = new NavigationPolygon(); var boundingOutline = new Vector2[] { new Vector2(0, 0), new Vector2(0, 50), new Vector2(50, 50), new Vector2(50, 0) }; newNavigationMesh.AddOutline(boundingOutline); NavigationServer2D.BakeFromSourceGeometryData(newNavigationMesh, new NavigationMeshSourceGeometryData2D()); GetNode<NavigationRegion2D>("NavigationRegion2D").NavigationPolygon = newNavigationMesh; [/csharp] [/codeblocks] Adding vertices and polygon indices manually. [codeblocks] [gdscript] var new_navigation_mesh = NavigationPolygon.new() var new_vertices = PackedVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)]) new_navigation_mesh.vertices = new_vertices var new_polygon_indices = PackedInt32Array([0, 1, 2, 3]) new_navigation_mesh.add_polygon(new_polygon_indices) $NavigationRegion2D.navigation_polygon = new_navigation_mesh [/gdscript] [csharp] var newNavigationMesh = new NavigationPolygon(); var newVertices = new Vector2[] { new Vector2(0, 0), new Vector2(0, 50), new Vector2(50, 50), new Vector2(50, 0) }; newNavigationMesh.Vertices = newVertices; var newPolygonIndices = new int[] { 0, 1, 2, 3 }; newNavigationMesh.AddPolygon(newPolygonIndices); GetNode<NavigationRegion2D>("NavigationRegion2D").NavigationPolygon = newNavigationMesh; [/csharp] [/codeblocks]

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AddOutline

func (self Instance) AddOutline(outline []Vector2.XY)

Appends a [PackedVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines.

func (Instance) AddOutlineAtIndex

func (self Instance) AddOutlineAtIndex(outline []Vector2.XY, index int)

Adds a [PackedVector2Array] that contains the vertices of an outline to the internal array that contains all the outlines at a fixed position.

func (Instance) AddPolygon

func (self Instance) AddPolygon(polygon []int32)

Adds a polygon using the indices of the vertices you get when calling [method get_vertices].

func (Instance) AgentRadius

func (self Instance) AgentRadius() Float.X

func (Instance) AsNavigationPolygon

func (self Instance) AsNavigationPolygon() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) BakingRect

func (self Instance) BakingRect() Rect2.PositionSize

func (Instance) BakingRectOffset

func (self Instance) BakingRectOffset() Vector2.XY

func (Instance) BorderSize

func (self Instance) BorderSize() Float.X

func (Instance) CellSize

func (self Instance) CellSize() Float.X

func (Instance) Clear

func (self Instance) Clear()

Clears the internal arrays for vertices and polygon indices.

func (Instance) ClearOutlines

func (self Instance) ClearOutlines()

Clears the array of the outlines, but it doesn't clear the vertices and the polygons that were created by them.

func (Instance) ClearPolygons

func (self Instance) ClearPolygons()

Clears the array of polygons, but it doesn't clear the array of outlines and vertices.

func (Instance) GetNavigationMesh

func (self Instance) GetNavigationMesh() [1]gdclass.NavigationMesh

Returns the [NavigationMesh] resulting from this navigation polygon. This navigation mesh can be used to update the navigation mesh of a region with the [method NavigationServer3D.region_set_navigation_mesh] API directly (as 2D uses the 3D server behind the scene).

func (Instance) GetOutline

func (self Instance) GetOutline(idx int) []Vector2.XY

Returns a [PackedVector2Array] containing the vertices of an outline that was created in the editor or by script.

func (Instance) GetOutlineCount

func (self Instance) GetOutlineCount() int

Returns the number of outlines that were created in the editor or by script.

func (Instance) GetParsedCollisionMaskValue

func (self Instance) GetParsedCollisionMaskValue(layer_number int) bool

Returns whether or not the specified layer of the [member parsed_collision_mask] is enabled, given a [param layer_number] between 1 and 32.

func (Instance) GetPolygon

func (self Instance) GetPolygon(idx int) []int32

Returns a [PackedInt32Array] containing the indices of the vertices of a created polygon.

func (Instance) GetPolygonCount

func (self Instance) GetPolygonCount() int

Returns the count of all polygons.

func (Instance) MakePolygonsFromOutlines

func (self Instance) MakePolygonsFromOutlines()

Creates polygons from the outlines added in the editor or by script.

func (Instance) ParsedCollisionMask

func (self Instance) ParsedCollisionMask() int

func (Instance) ParsedGeometryType

func (self Instance) ParsedGeometryType() gdclass.NavigationPolygonParsedGeometryType

func (Instance) RemoveOutline

func (self Instance) RemoveOutline(idx int)

Removes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update.

func (Instance) SetAgentRadius

func (self Instance) SetAgentRadius(value Float.X)

func (Instance) SetBakingRect

func (self Instance) SetBakingRect(value Rect2.PositionSize)

func (Instance) SetBakingRectOffset

func (self Instance) SetBakingRectOffset(value Vector2.XY)

func (Instance) SetBorderSize

func (self Instance) SetBorderSize(value Float.X)

func (Instance) SetCellSize

func (self Instance) SetCellSize(value Float.X)

func (Instance) SetOutline

func (self Instance) SetOutline(idx int, outline []Vector2.XY)

Changes an outline created in the editor or by script. You have to call [method make_polygons_from_outlines] for the polygons to update.

func (Instance) SetParsedCollisionMask

func (self Instance) SetParsedCollisionMask(value int)

func (Instance) SetParsedCollisionMaskValue

func (self Instance) SetParsedCollisionMaskValue(layer_number int, value bool)

Based on [param value], enables or disables the specified layer in the [member parsed_collision_mask], given a [param layer_number] between 1 and 32.

func (Instance) SetParsedGeometryType

func (self Instance) SetParsedGeometryType(value gdclass.NavigationPolygonParsedGeometryType)

func (Instance) SetSourceGeometryGroupName

func (self Instance) SetSourceGeometryGroupName(value string)

func (Instance) SetSourceGeometryMode

func (self Instance) SetSourceGeometryMode(value gdclass.NavigationPolygonSourceGeometryMode)

func (Instance) SetVertices

func (self Instance) SetVertices(value []Vector2.XY)

func (Instance) SourceGeometryGroupName

func (self Instance) SourceGeometryGroupName() string

func (Instance) SourceGeometryMode

func (self Instance) SourceGeometryMode() gdclass.NavigationPolygonSourceGeometryMode

func (*Instance) UnsafePointer

func (self *Instance) UnsafePointer() unsafe.Pointer

func (Instance) Vertices

func (self Instance) Vertices() []Vector2.XY

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type ParsedGeometryType

type ParsedGeometryType = gdclass.NavigationPolygonParsedGeometryType //gd:NavigationPolygon.ParsedGeometryType
const (
	/*Parses mesh instances as obstruction geometry. This includes [Polygon2D], [MeshInstance2D], [MultiMeshInstance2D], and [TileMap] nodes.
	  Meshes are only parsed when they use a 2D vertices surface format.*/
	ParsedGeometryMeshInstances ParsedGeometryType = 0
	/*Parses [StaticBody2D] and [TileMap] colliders as obstruction geometry. The collider should be in any of the layers specified by [member parsed_collision_mask].*/
	ParsedGeometryStaticColliders ParsedGeometryType = 1
	/*Both [constant PARSED_GEOMETRY_MESH_INSTANCES] and [constant PARSED_GEOMETRY_STATIC_COLLIDERS].*/
	ParsedGeometryBoth ParsedGeometryType = 2
	/*Represents the size of the [enum ParsedGeometryType] enum.*/
	ParsedGeometryMax ParsedGeometryType = 3
)

type SourceGeometryMode

type SourceGeometryMode = gdclass.NavigationPolygonSourceGeometryMode //gd:NavigationPolygon.SourceGeometryMode
const (
	/*Scans the child nodes of the root node recursively for geometry.*/
	SourceGeometryRootNodeChildren SourceGeometryMode = 0
	/*Scans nodes in a group and their child nodes recursively for geometry. The group is specified by [member source_geometry_group_name].*/
	SourceGeometryGroupsWithChildren SourceGeometryMode = 1
	/*Uses nodes in a group for geometry. The group is specified by [member source_geometry_group_name].*/
	SourceGeometryGroupsExplicit SourceGeometryMode = 2
	/*Represents the size of the [enum SourceGeometryMode] enum.*/
	SourceGeometryMax SourceGeometryMode = 3
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL