Table of Contents

Class NavigationLink2D

Namespace
Godot
Assembly
GodotSharp.dll

A link between two positions on NavigationRegion2Ds that agents can be routed through. These positions can be on the same NavigationRegion2D or on two different ones. Links are useful to express navigation methods other than traveling along the surface of the navigation polygon, such as ziplines, teleporters, or gaps that can be jumped across.

public class NavigationLink2D : Node2D, IDisposable
Inheritance
NavigationLink2D
Implements
Inherited Members

Constructors

NavigationLink2D()

public NavigationLink2D()

Properties

Bidirectional

Whether this link can be traveled in both directions or only from StartPosition to EndPosition.

public bool Bidirectional { get; set; }

Property Value

bool

Enabled

Whether this link is currently active. If false, MapGetPath(Rid, Vector2, Vector2, bool, uint) will ignore this link.

public bool Enabled { get; set; }

Property Value

bool

EndPosition

Ending position of the link.

This position will search out the nearest polygon in the navigation mesh to attach to.

The distance the link will search is controlled by MapSetLinkConnectionRadius(Rid, float).

public Vector2 EndPosition { get; set; }

Property Value

Vector2

EnterCost

When pathfinding enters this link 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

float

NavigationLayers

A bitfield determining all navigation layers the link belongs to. These navigation layers will be checked when requesting a path with MapGetPath(Rid, Vector2, Vector2, bool, uint).

public uint NavigationLayers { get; set; }

Property Value

uint

StartPosition

Starting position of the link.

This position will search out the nearest polygon in the navigation mesh to attach to.

The distance the link will search is controlled by MapSetLinkConnectionRadius(Rid, float).

public Vector2 StartPosition { get; set; }

Property Value

Vector2

TravelCost

When pathfinding moves along the link the traveled distance is multiplied with TravelCost for determining the shortest path.

public float TravelCost { get; set; }

Property Value

float

Methods

GetGlobalEndPosition()

Returns the EndPosition that is relative to the link as a global position.

public Vector2 GetGlobalEndPosition()

Returns

Vector2

GetGlobalStartPosition()

Returns the StartPosition that is relative to the link as a global position.

public Vector2 GetGlobalStartPosition()

Returns

Vector2

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

bool

GetRid()

Returns the Rid of this link on the NavigationServer2D.

public Rid GetRid()

Returns

Rid

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_name

Name of the method to check for.

Returns

bool

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_name

Name of the signal to check for.

Returns

bool

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_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

SetGlobalEndPosition(Vector2)

Sets the EndPosition that is relative to the link from a global position.

public void SetGlobalEndPosition(Vector2 position)

Parameters

position Vector2

SetGlobalStartPosition(Vector2)

Sets the StartPosition that is relative to the link from a global position.

public void SetGlobalStartPosition(Vector2 position)

Parameters

position Vector2

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

layerNumber int
value bool