:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/Navigation2D.xml. .. _class_Navigation2D: Navigation2D ============ **Inherits:** :ref:`Node2D` **<** :ref:`CanvasItem` **<** :ref:`Node` **<** :ref:`Object` 2D navigation and pathfinding node. .. rst-class:: classref-introduction-group Description ----------- *Deprecated.* **Navigation2D** node and :ref:`get_simple_path` are deprecated and will be removed in a future version. Use :ref:`Navigation2DServer.map_get_path` instead. Navigation2D provides navigation and pathfinding within a 2D area, specified as a collection of :ref:`NavigationPolygon` resources. By default, these are automatically collected from child :ref:`NavigationPolygonInstance` nodes. .. rst-class:: classref-introduction-group Tutorials --------- - `2D Navigation Demo `__ .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +---------------------------+-----------------------------------------------------------------------------------+---------+ | :ref:`float` | :ref:`cell_size` | ``1.0`` | +---------------------------+-----------------------------------------------------------------------------------+---------+ | :ref:`float` | :ref:`edge_connection_margin` | ``1.0`` | +---------------------------+-----------------------------------------------------------------------------------+---------+ | :ref:`int` | :ref:`navigation_layers` | ``1`` | +---------------------------+-----------------------------------------------------------------------------------+---------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Vector2` | :ref:`get_closest_point` **(** :ref:`Vector2` to_point **)** |const| | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`RID` | :ref:`get_closest_point_owner` **(** :ref:`Vector2` to_point **)** |const| | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`RID` | :ref:`get_rid` **(** **)** |const| | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PoolVector2Array` | :ref:`get_simple_path` **(** :ref:`Vector2` start, :ref:`Vector2` end, :ref:`bool` optimize=true **)** |const| | +-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_Navigation2D_property_cell_size: .. rst-class:: classref-property :ref:`float` **cell_size** = ``1.0`` .. rst-class:: classref-property-setget - void **set_cell_size** **(** :ref:`float` value **)** - :ref:`float` **get_cell_size** **(** **)** The XY plane cell size to use for fields. .. rst-class:: classref-item-separator ---- .. _class_Navigation2D_property_edge_connection_margin: .. rst-class:: classref-property :ref:`float` **edge_connection_margin** = ``1.0`` .. rst-class:: classref-property-setget - void **set_edge_connection_margin** **(** :ref:`float` value **)** - :ref:`float` **get_edge_connection_margin** **(** **)** This value is used to detect the near edges to connect compatible regions. .. rst-class:: classref-item-separator ---- .. _class_Navigation2D_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 map layers the navigation can use on a :ref:`get_simple_path` path query. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_Navigation2D_method_get_closest_point: .. rst-class:: classref-method :ref:`Vector2` **get_closest_point** **(** :ref:`Vector2` to_point **)** |const| Returns the navigation point closest to the point given. Points are in local coordinate space. .. rst-class:: classref-item-separator ---- .. _class_Navigation2D_method_get_closest_point_owner: .. rst-class:: classref-method :ref:`RID` **get_closest_point_owner** **(** :ref:`Vector2` to_point **)** |const| Returns the owner of the :ref:`NavigationPolygon` which contains the navigation point closest to the point given. This is usually a :ref:`NavigationPolygonInstance`. .. rst-class:: classref-item-separator ---- .. _class_Navigation2D_method_get_rid: .. rst-class:: classref-method :ref:`RID` **get_rid** **(** **)** |const| Returns the object's :ref:`RID`. .. rst-class:: classref-item-separator ---- .. _class_Navigation2D_method_get_simple_path: .. rst-class:: classref-method :ref:`PoolVector2Array` **get_simple_path** **(** :ref:`Vector2` start, :ref:`Vector2` end, :ref:`bool` optimize=true **)** |const| *Deprecated.* **Navigation2D** node and :ref:`get_simple_path` are deprecated and will be removed in a future version. Use :ref:`Navigation2DServer.map_get_path` instead. Returns the path between two given points. Points are in local coordinate space. If ``optimize`` is ``true`` (the default), the path is smoothed by merging path segments where possible. .. |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.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`