NavigationLink2D

Experimental: This class may be changed or removed in future versions.

Inherits:Node2D<CanvasItem<Node<Object

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

Description

A link between two positions onNavigationRegion2Ds that agents can be routed through. These positions can be on the sameNavigationRegion2D 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.

Tutorials

Properties

bool

bidirectional

true

bool

enabled

true

Vector2

end_position

Vector2(0,0)

float

enter_cost

0.0

int

navigation_layers

1

Vector2

start_position

Vector2(0,0)

float

travel_cost

1.0

Methods

Vector2

get_global_end_position()const

Vector2

get_global_start_position()const

bool

get_navigation_layer_value(layer_number:int)const

RID

get_navigation_map()const

RID

get_rid()const

void

set_global_end_position(position:Vector2)

void

set_global_start_position(position:Vector2)

void

set_navigation_layer_value(layer_number:int, value:bool)

void

set_navigation_map(navigation_map:RID)


Property Descriptions

boolbidirectional =true🔗

Whether this link can be traveled in both directions or only fromstart_position toend_position.


boolenabled =true🔗

Whether this link is currently active. Iffalse,NavigationServer2D.map_get_path() will ignore this link.


Vector2end_position =Vector2(0,0)🔗

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 byNavigationServer2D.map_set_link_connection_radius().


floatenter_cost =0.0🔗

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


intnavigation_layers =1🔗

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


Vector2start_position =Vector2(0,0)🔗

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 byNavigationServer2D.map_set_link_connection_radius().


floattravel_cost =1.0🔗

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


Method Descriptions

Vector2get_global_end_position()const🔗

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


Vector2get_global_start_position()const🔗

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


boolget_navigation_layer_value(layer_number:int)const🔗

Returns whether or not the specified layer of thenavigation_layers bitmask is enabled, given alayer_number between 1 and 32.


RIDget_navigation_map()const🔗

Returns the current navigation mapRID used by this link.


RIDget_rid()const🔗

Returns theRID of this link on theNavigationServer2D.


voidset_global_end_position(position:Vector2)🔗

Sets theend_position that is relative to the link from a globalposition.


voidset_global_start_position(position:Vector2)🔗

Sets thestart_position that is relative to the link from a globalposition.


voidset_navigation_layer_value(layer_number:int, value:bool)🔗

Based onvalue, enables or disables the specified layer in thenavigation_layers bitmask, given alayer_number between 1 and 32.


voidset_navigation_map(navigation_map:RID)🔗

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


User-contributed notes

Please read theUser-contributed notes policy before submitting a comment.