NavigationRegion2D

package
v0.0.0-...-9b8b246 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

A traversable 2D region based on a NavigationPolygon that NavigationAgent2Ds can use for pathfinding.

Two regions can be connected to each other if they share a similar edge. You can set the minimum distance between two vertices required to connect two edges by using NavigationServer2D.MapSetEdgeConnectionMargin.

Note: Overlapping two regions' navigation polygons is not enough for connecting two regions. They must share a similar edge.

The pathfinding cost of entering a region from another region can be controlled with the EnterCost value.

Note: This value is not added to the path cost when the start position is already inside this region.

The pathfinding cost of traveling distances inside this region can be controlled with the TravelCost multiplier.

Note: This node caches changes to its properties, so if you make changes to the underlying region Resource.ID in NavigationServer2D, they will not be reflected in this node's properties.

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
	AsNavigationRegion2D() Instance
}

type Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsCanvasItem

func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance

func (*Extension[T]) AsNavigationRegion2D

func (self *Extension[T]) AsNavigationRegion2D() Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsNode2D

func (self *Extension[T]) AsNode2D() Node2D.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.NavigationRegion2D

Instance of the class with convieniently typed arguments and results.

var Nil Instance

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

func New

func New() Instance

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsNavigationRegion2D

func (self Instance) AsNavigationRegion2D() Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsNode2D

func (self Instance) AsNode2D() Node2D.Instance

func (Instance) AsObject

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

func (Instance) BakeNavigationPolygon

func (self Instance) BakeNavigationPolygon()

Bakes the NavigationPolygon. If 'on_thread' is set to true (default), the baking is done on a separate thread.

func (Instance) Enabled

func (self Instance) Enabled() bool

Determines if the NavigationRegion2D is enabled or disabled.

func (Instance) EnterCost

func (self Instance) EnterCost() Float.X

When pathfinding enters this region's navigation mesh from another regions navigation mesh the EnterCost value is added to the path distance for determining the shortest path.

func (Instance) GetBounds

func (self Instance) GetBounds() Rect2.PositionSize

Returns the axis-aligned rectangle for the region's transformed navigation mesh.

func (Instance) GetNavigationLayerValue

func (self Instance) GetNavigationLayerValue(layer_number int) bool

Returns whether or not the specified layer of the NavigationLayers bitmask is enabled, given a 'layer_number' between 1 and 32.

func (Instance) GetNavigationMap

func (self Instance) GetNavigationMap() RID.NavigationMap2D

Returns the current navigation map Resource.ID used by this region.

func (Instance) GetRegionRid

func (self Instance) GetRegionRid() RID.NavigationRegion2D

Returns the Resource.ID of this region on the NavigationServer2D.

func (Instance) GetRid

func (self Instance) GetRid() RID.NavigationRegion2D

Returns the Resource.ID of this region on the NavigationServer2D. Combined with NavigationServer2D.MapGetClosestPointOwner can be used to identify the NavigationRegion2D closest to a point on the merged navigation map.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IsBaking

func (self Instance) IsBaking() bool

Returns true when the NavigationPolygon is being baked on a background thread.

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (Instance) NavigationLayers

func (self Instance) NavigationLayers() int

A bitfield determining all navigation layers the region belongs to. These navigation layers can be checked upon when requesting a path with NavigationServer2D.MapGetPath.

func (Instance) NavigationPolygon

func (self Instance) NavigationPolygon() NavigationPolygon.Instance

The NavigationPolygon resource to use.

func (Instance) OnBakeFinished

func (self Instance) OnBakeFinished(cb func(), flags ...Signal.Flags)

Emitted when a navigation polygon bake operation is completed.

func (Instance) OnNavigationPolygonChanged

func (self Instance) OnNavigationPolygonChanged(cb func(), flags ...Signal.Flags)

Emitted when the used navigation polygon is replaced or changes to the internals of the current navigation polygon are committed.

func (Instance) SetEnabled

func (self Instance) SetEnabled(value bool)

SetEnabled sets the property returned by [IsEnabled].

func (Instance) SetEnterCost

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

SetEnterCost sets the property returned by [GetEnterCost].

func (Instance) SetNavigationLayerValue

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

Based on 'value', enables or disables the specified layer in the NavigationLayers bitmask, given a 'layer_number' between 1 and 32.

func (Instance) SetNavigationLayers

func (self Instance) SetNavigationLayers(value int)

SetNavigationLayers sets the property returned by [GetNavigationLayers].

func (Instance) SetNavigationMap

func (self Instance) SetNavigationMap(navigation_map RID.NavigationMap2D)

Sets the Resource.ID of the navigation map this region should use. By default the region will automatically join the World2D default navigation map so this function is only required to override the default map.

func (Instance) SetNavigationPolygon

func (self Instance) SetNavigationPolygon(value NavigationPolygon.Instance)

SetNavigationPolygon sets the property returned by [GetNavigationPolygon].

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetTravelCost

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

SetTravelCost sets the property returned by [GetTravelCost].

func (Instance) SetUseEdgeConnections

func (self Instance) SetUseEdgeConnections(value bool)

SetUseEdgeConnections sets the property returned by [GetUseEdgeConnections].

func (Instance) TravelCost

func (self Instance) TravelCost() Float.X

When pathfinding moves inside this region's navigation mesh the traveled distances are multiplied with TravelCost for determining the shortest path.

func (Instance) UseEdgeConnections

func (self Instance) UseEdgeConnections() bool

If enabled the navigation region will use edge connections to connect with other navigation regions within proximity of the navigation map edge connection margin.

func (Instance) Virtual

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

type MoreArgs

type MoreArgs [1]gdclass.NavigationRegion2D

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) BakeNavigationPolygon

func (self MoreArgs) BakeNavigationPolygon(on_thread bool)

Bakes the NavigationPolygon. If 'on_thread' is set to true (default), the baking is done on a separate thread.

Jump to

Keyboard shortcuts

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