Table of Contents

Class NavigationLink2D

A link between two positions on NavigationRegion2Ds that agents can be routed through.

Inheritance
NavigationLink2D

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.

See Also

Properties

Whether this link can be traveled in both directions or only from start_position to end_position.

var bidirectional : bool = true

Property Value

bool
  • void set_bidirectional(bool value)
  • bool is_bidirectional

Whether this link is currently active. If false, NavigationServer2D.map_get_path will ignore this link.

var enabled : bool = true

Property Value

bool
  • void set_enabled(bool value)
  • bool is_enabled

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 NavigationServer2D.map_set_link_connection_radius.

var end_position : Vector2 = Vector2(0, 0)

Property Value

Vector2

When pathfinding enters this link from another regions navigation mesh the enter_cost value is added to the path distance for determining the shortest path.

var enter_cost : float = 0.0

Property Value

float
  • void set_enter_cost(float value)
  • float get_enter_cost

A bitfield determining all navigation layers the link belongs to. These navigation layers will be checked when requesting a path with NavigationServer2D.map_get_path.

var navigation_layers : int = 1

Property Value

int
  • void set_navigation_layers(int value)
  • int get_navigation_layers

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 NavigationServer2D.map_set_link_connection_radius.

var start_position : Vector2 = Vector2(0, 0)

Property Value

Vector2

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

var travel_cost : float = 1.0

Property Value

float
  • void set_travel_cost(float value)
  • float get_travel_cost

Methods

Qualifiers: const

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

Vector2 get_global_end_position

Qualifiers: const

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

Vector2 get_global_start_position

Qualifiers: const

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

bool get_navigation_layer_value(int layer_number)

Parameters

layer_number int

Qualifiers: const

Returns the current navigation map RID used by this link.

RID get_navigation_map

Qualifiers: const

Returns the RID of this link on the NavigationServer2D.

RID get_rid

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

void set_global_end_position(Vector2 position)

Parameters

position Vector2

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

void set_global_start_position(Vector2 position)

Parameters

position Vector2

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

void set_navigation_layer_value(int layer_number, bool value)

Parameters

layer_number int
value bool

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

void set_navigation_map(RID navigation_map)

Parameters

navigation_map RID