Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
NavigationRegion2D¶
Inherits: Node2D < CanvasItem < Node < Object
A traversable 2D region that NavigationAgent2Ds can use for pathfinding.
Description¶
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.map_set_edge_connection_margin.
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 enter_cost 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 travel_cost multiplier.
Note: This node caches changes to its properties, so if you make changes to the underlying region RID in NavigationServer2D, they will not be reflected in this node's properties.
Tutorials¶
Properties¶
|
||
|
||
|
||
|
||
|
||
|
||
|
Methods¶
void |
bake_navigation_polygon ( bool on_thread=true ) |
get_avoidance_layer_value ( int layer_number ) const |
|
get_navigation_layer_value ( int layer_number ) const |
|
get_navigation_map ( ) const |
|
get_region_rid ( ) const |
|
void |
set_avoidance_layer_value ( int layer_number, bool value ) |
void |
set_navigation_layer_value ( int layer_number, bool value ) |
void |
set_navigation_map ( RID navigation_map ) |
Signals¶
bake_finished ( )
Emitted when a navigation polygon bake operation is completed.
navigation_polygon_changed ( )
Emitted when the used navigation polygon is replaced or changes to the internals of the current navigation polygon are committed.
Property Descriptions¶
int avoidance_layers = 1
A bitfield determining all avoidance layers for the avoidance constrain.
bool constrain_avoidance = false
If true
constraints avoidance agent's with an avoidance mask bit that matches with a bit of the avoidance_layers to the navigation polygon. Due to each navigation polygon outline creating an obstacle and each polygon edge creating an avoidance line constrain keep the navigation polygon shape as simple as possible for performance.
Experimental: This is an experimental feature and should not be used in production as agent's can get stuck on the navigation polygon corners and edges especially at high frame rate.
bool enabled = true
Determines if the NavigationRegion2D is enabled or disabled.
float enter_cost = 0.0
When pathfinding enters this region's navigation mesh from another regions navigation mesh the enter_cost
value is added to the path distance for determining the shortest path.
int navigation_layers = 1
A bitfield determining all navigation layers the region belongs to. These navigation layers can be checked upon when requesting a path with NavigationServer2