Class NavigationRegion3D
- Namespace
- Godot
- Assembly
- GodotSharp.dll
A traversable 3D region based on a NavigationMesh that NavigationAgent3Ds 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 MapSetEdgeConnectionMargin(Rid, float).
Note: Overlapping two regions' navigation meshes is not enough for connecting two regions. They must share a similar edge.
The cost of entering this 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 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 Rid in NavigationServer3D, they will not be reflected in this node's properties.
public class NavigationRegion3D : Node3D, IDisposable
- Inheritance
-
NavigationRegion3D
- Implements
- Inherited Members
Constructors
NavigationRegion3D()
public NavigationRegion3D()
Properties
Enabled
Determines if the NavigationRegion3D is enabled or disabled.
public bool Enabled { get; set; }
Property Value
EnterCost
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.
public float EnterCost { get; set; }
Property Value
NavigationLayers
A bitfield determining all navigation layers the region belongs to. These navigation layers can be checked upon when requesting a path with MapGetPath(Rid, Vector3, Vector3, bool, uint).
public uint NavigationLayers { get; set; }
Property Value
NavigationMesh
The NavigationMesh resource to use.
public NavigationMesh NavigationMesh { get; set; }
Property Value
TravelCost
When pathfinding moves inside this region's navigation mesh the traveled distances are multiplied with TravelCost for determining the shortest path.
public float TravelCost { get; set; }
Property Value
UseEdgeConnections
If enabled the navigation region will use edge connections to connect with other navigation regions within proximity of the navigation map edge connection margin.
public bool UseEdgeConnections { get; set; }
Property Value
Methods
BakeNavigationMesh(bool)
Bakes the NavigationMesh. If onThread
is set to true
(default), the baking is done on a separate thread. Baking on separate thread is useful because navigation baking is not a cheap operation. When it is completed, it automatically sets the new NavigationMesh. Please note that baking on separate thread may be very slow if geometry is parsed from meshes as async access to each mesh involves heavy synchronization. Also, please note that baking on a separate thread is automatically disabled on operating systems that cannot use threads (such as Web with threads disabled).
public void BakeNavigationMesh(bool onThread = true)
Parameters
onThread
bool
GetNavigationLayerValue(int)
Returns whether or not the specified layer of the NavigationLayers bitmask is enabled, given a layerNumber
between 1 and 32.
public bool GetNavigationLayerValue(int layerNumber)
Parameters
layerNumber
int
Returns
GetNavigationMap()
Returns the current navigation map Rid used by this region.
public Rid GetNavigationMap()
Returns
GetRegionRid()
Returns the Rid of this region on the NavigationServer3D.
Deprecated. Use GetRid() instead.
[Obsolete("This method is deprecated.")]
public Rid GetRegionRid()
Returns
GetRid()
Returns the Rid of this region on the NavigationServer3D. Combined with MapGetClosestPointOwner(Rid, Vector3) can be used to identify the NavigationRegion3D closest to a point on the merged navigation map.
public Rid GetRid()
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
SetNavigationLayerValue(int, bool)
Based on value
, enables or disables the specified layer in the NavigationLayers bitmask, given a layerNumber
between 1 and 32.
public void SetNavigationLayerValue(int layerNumber, bool value)
Parameters
SetNavigationMap(Rid)
Sets the Rid of the navigation map this region should use. By default the region will automatically join the World3D default navigation map so this function is only required to override the default map.
public void SetNavigationMap(Rid navigationMap)
Parameters
navigationMap
Rid
Events
BakeFinished
Notifies when the navigation mesh bake operation is completed.
public event Action BakeFinished
Event Type
NavigationMeshChanged
Notifies when the NavigationMesh has changed.
public event Action NavigationMeshChanged