Files
godot-docs/classes/class_navigation2d.rst
2022-04-29 14:16:57 +02:00

117 lines
6.3 KiB
ReStructuredText

:github_url: hide
.. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the Navigation2D.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.
.. _class_Navigation2D:
Navigation2D
============
**Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
2D navigation and pathfinding node.
Description
-----------
Navigation2D provides navigation and pathfinding within a 2D area, specified as a collection of :ref:`NavigationPolygon<class_NavigationPolygon>` resources. By default, these are automatically collected from child :ref:`NavigationPolygonInstance<class_NavigationPolygonInstance>` nodes.
Tutorials
---------
- `2D Navigation Demo <https://godotengine.org/asset-library/asset/117>`__
Properties
----------
+---------------------------+-----------------------------------------------------------------------------------+---------+
| :ref:`float<class_float>` | :ref:`cell_size<class_Navigation2D_property_cell_size>` | ``1.0`` |
+---------------------------+-----------------------------------------------------------------------------------+---------+
| :ref:`float<class_float>` | :ref:`edge_connection_margin<class_Navigation2D_property_edge_connection_margin>` | ``1.0`` |
+---------------------------+-----------------------------------------------------------------------------------+---------+
Methods
-------
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Vector2<class_Vector2>` | :ref:`get_closest_point<class_Navigation2D_method_get_closest_point>` **(** :ref:`Vector2<class_Vector2>` to_point **)** |const| |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`RID<class_RID>` | :ref:`get_closest_point_owner<class_Navigation2D_method_get_closest_point_owner>` **(** :ref:`Vector2<class_Vector2>` to_point **)** |const| |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`RID<class_RID>` | :ref:`get_rid<class_Navigation2D_method_get_rid>` **(** **)** |const| |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PoolVector2Array<class_PoolVector2Array>` | :ref:`get_simple_path<class_Navigation2D_method_get_simple_path>` **(** :ref:`Vector2<class_Vector2>` start, :ref:`Vector2<class_Vector2>` end, :ref:`bool<class_bool>` optimize=true **)** |const| |
+-------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Property Descriptions
---------------------
.. _class_Navigation2D_property_cell_size:
- :ref:`float<class_float>` **cell_size**
+-----------+----------------------+
| *Default* | ``1.0`` |
+-----------+----------------------+
| *Setter* | set_cell_size(value) |
+-----------+----------------------+
| *Getter* | get_cell_size() |
+-----------+----------------------+
The XY plane cell size to use for fields.
----
.. _class_Navigation2D_property_edge_connection_margin:
- :ref:`float<class_float>` **edge_connection_margin**
+-----------+-----------------------------------+
| *Default* | ``1.0`` |
+-----------+-----------------------------------+
| *Setter* | set_edge_connection_margin(value) |
+-----------+-----------------------------------+
| *Getter* | get_edge_connection_margin() |
+-----------+-----------------------------------+
This value is used to detect the near edges to connect compatible regions.
Method Descriptions
-------------------
.. _class_Navigation2D_method_get_closest_point:
- :ref:`Vector2<class_Vector2>` **get_closest_point** **(** :ref:`Vector2<class_Vector2>` to_point **)** |const|
Returns the navigation point closest to the point given. Points are in local coordinate space.
----
.. _class_Navigation2D_method_get_closest_point_owner:
- :ref:`RID<class_RID>` **get_closest_point_owner** **(** :ref:`Vector2<class_Vector2>` to_point **)** |const|
Returns the owner of the :ref:`NavigationPolygon<class_NavigationPolygon>` which contains the navigation point closest to the point given. This is usually a :ref:`NavigationPolygonInstance<class_NavigationPolygonInstance>`.
----
.. _class_Navigation2D_method_get_rid:
- :ref:`RID<class_RID>` **get_rid** **(** **)** |const|
Returns the object's :ref:`RID<class_RID>`.
----
.. _class_Navigation2D_method_get_simple_path:
- :ref:`PoolVector2Array<class_PoolVector2Array>` **get_simple_path** **(** :ref:`Vector2<class_Vector2>` start, :ref:`Vector2<class_Vector2>` end, :ref:`bool<class_bool>` optimize=true **)** |const|
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.)`