:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/4.0/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/4.0/doc/classes/NavigationLink2D.xml. .. _class_NavigationLink2D: NavigationLink2D ================ **Inherits:** :ref:`Node2D` **<** :ref:`CanvasItem` **<** :ref:`Node` **<** :ref:`Object` Creates a link between two positions that :ref:`NavigationServer2D` can route agents through. .. rst-class:: classref-introduction-group Description ----------- Creates a link between two positions that :ref:`NavigationServer2D` can route agents through. Links can be used to express navigation methods that aren't just traveling along the surface of the navigation mesh, like zip-lines, teleporters, or jumping across gaps. .. rst-class:: classref-introduction-group Tutorials --------- - :doc:`Using NavigationLinks <../tutorials/navigation/navigation_using_navigationlinks>` .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +-------------------------------+-----------------------------------------------------------------------------+-------------------+ | :ref:`bool` | :ref:`bidirectional` | ``true`` | +-------------------------------+-----------------------------------------------------------------------------+-------------------+ | :ref:`bool` | :ref:`enabled` | ``true`` | +-------------------------------+-----------------------------------------------------------------------------+-------------------+ | :ref:`Vector2` | :ref:`end_position` | ``Vector2(0, 0)`` | +-------------------------------+-----------------------------------------------------------------------------+-------------------+ | :ref:`float` | :ref:`enter_cost` | ``0.0`` | +-------------------------------+-----------------------------------------------------------------------------+-------------------+ | :ref:`int` | :ref:`navigation_layers` | ``1`` | +-------------------------------+-----------------------------------------------------------------------------+-------------------+ | :ref:`Vector2` | :ref:`start_position` | ``Vector2(0, 0)`` | +-------------------------------+-----------------------------------------------------------------------------+-------------------+ | :ref:`float` | :ref:`travel_cost` | ``1.0`` | +-------------------------------+-----------------------------------------------------------------------------+-------------------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_global_end_position` **(** **)** |const| | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_global_start_position` **(** **)** |const| | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`get_navigation_layer_value` **(** :ref:`int` layer_number **)** |const| | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_global_end_position` **(** :ref:`Vector2` position **)** | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_global_start_position` **(** :ref:`Vector2` position **)** | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_navigation_layer_value` **(** :ref:`int` layer_number, :ref:`bool` value **)** | +-------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_NavigationLink2D_property_bidirectional: .. rst-class:: classref-property :ref:`bool` **bidirectional** = ``true`` .. rst-class:: classref-property-setget - void **set_bidirectional** **(** :ref:`bool` value **)** - :ref:`bool` **is_bidirectional** **(** **)** Whether this link can be traveled in both directions or only from :ref:`start_position` to :ref:`end_position`. .. rst-class:: classref-item-separator ---- .. _class_NavigationLink2D_property_enabled: .. rst-class:: classref-property :ref:`bool` **enabled** = ``true`` .. rst-class:: classref-property-setget - void **set_enabled** **(** :ref:`bool` value **)** - :ref:`bool` **is_enabled** **(** **)** Whether this link is currently active. If ``false``, :ref:`NavigationServer2D.map_get_path` will ignore this link. .. rst-class:: classref-item-separator ---- .. _class_NavigationLink2D_property_end_position: .. rst-class:: classref-property :ref:`Vector2` **end_position** = ``Vector2(0, 0)`` .. rst-class:: classref-property-setget - void **set_end_position** **(** :ref:`Vector2` value **)** - :ref:`Vector2` **get_end_position** **(** **)** 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 :ref:`NavigationServer2D.map_set_link_connection_radius`. .. rst-class:: classref-item-separator ---- .. _class_NavigationLink2D_property_enter_cost: .. rst-class:: classref-property :ref:`float` **enter_cost** = ``0.0`` .. rst-class:: classref-property-setget - void **set_enter_cost** **(** :ref:`float` value **)** - :ref:`float` **get_enter_cost** **(** **)** When pathfinding enters this link from another regions navigation mesh the :ref:`enter_cost` value is added to the path distance for determining the shortest path. .. rst-class:: classref-item-separator ---- .. _class_NavigationLink2D_property_navigation_layers: .. rst-class:: classref-property :ref:`int` **navigation_layers** = ``1`` .. rst-class:: classref-property-setget - void **set_navigation_layers** **(** :ref:`int` value **)** - :ref:`int` **get_navigation_layers** **(** **)** A bitfield determining all navigation layers the link belongs to. These navigation layers will be checked when requesting a path with :ref:`NavigationServer2D.map_get_path`. .. rst-class:: classref-item-separator ---- .. _class_NavigationLink2D_property_start_position: .. rst-class:: classref-property :ref:`Vector2` **start_position** = ``Vector2(0, 0)`` .. rst-class:: classref-property-setget - void **set_start_position** **(** :ref:`Vector2` value **)** - :ref:`Vector2` **get_start_position** **(** **)** 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 :ref:`NavigationServer2D.map_set_link_connection_radius`. .. rst-class:: classref-item-separator ---- .. _class_NavigationLink2D_property_travel_cost: .. rst-class:: classref-property :ref:`float` **travel_cost** = ``1.0`` .. rst-class:: classref-property-setget - void **set_travel_cost** **(** :ref:`float` value **)** - :ref:`float` **get_travel_cost** **(** **)** When pathfinding moves along the link the traveled distance is multiplied with :ref:`travel_cost` for determining the shortest path. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_NavigationLink2D_method_get_global_end_position: .. rst-class:: classref-method :ref:`Vector2` **get_global_end_position** **(** **)** |const| Returns the :ref:`end_position` that is relative to the link as a global position. .. rst-class:: classref-item-separator ---- .. _class_NavigationLink2D_method_get_global_start_position: .. rst-class:: classref-method :ref:`Vector2` **get_global_start_position** **(** **)** |const| Returns the :ref:`start_position` that is relative to the link as a global position. .. rst-class:: classref-item-separator ---- .. _class_NavigationLink2D_method_get_navigation_layer_value: .. rst-class:: classref-method :ref:`bool` **get_navigation_layer_value** **(** :ref:`int` layer_number **)** |const| Returns whether or not the specified layer of the :ref:`navigation_layers` bitmask is enabled, given a ``layer_number`` between 1 and 32. .. rst-class:: classref-item-separator ---- .. _class_NavigationLink2D_method_set_global_end_position: .. rst-class:: classref-method void **set_global_end_position** **(** :ref:`Vector2` position **)** Sets the :ref:`end_position` that is relative to the link from a global ``position``. .. rst-class:: classref-item-separator ---- .. _class_NavigationLink2D_method_set_global_start_position: .. rst-class:: classref-method void **set_global_start_position** **(** :ref:`Vector2` position **)** Sets the :ref:`start_position` that is relative to the link from a global ``position``. .. rst-class:: classref-item-separator ---- .. _class_NavigationLink2D_method_set_navigation_layer_value: .. rst-class:: classref-method void **set_navigation_layer_value** **(** :ref:`int` layer_number, :ref:`bool` value **)** Based on ``value``, enables or disables the specified layer in the :ref:`navigation_layers` bitmask, given a ``layer_number`` between 1 and 32. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`