mirror of
https://github.com/godotengine/godot-docs.git
synced 2025-12-31 17:49:03 +03:00
355 lines
17 KiB
ReStructuredText
355 lines
17 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. DO NOT EDIT THIS FILE!!!
|
|
.. Generated automatically from Godot engine sources.
|
|
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
|
|
.. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/NavigationRegion2D.xml.
|
|
|
|
.. _class_NavigationRegion2D:
|
|
|
|
NavigationRegion2D
|
|
==================
|
|
|
|
**Experimental:** This class may be changed or removed in future versions.
|
|
|
|
**Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
|
|
|
A traversable 2D region that :ref:`NavigationAgent2D<class_NavigationAgent2D>`\ s can use for pathfinding.
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
Description
|
|
-----------
|
|
|
|
A traversable 2D region based on a :ref:`NavigationPolygon<class_NavigationPolygon>` that :ref:`NavigationAgent2D<class_NavigationAgent2D>`\ s can use for pathfinding.
|
|
|
|
Two regions can be connected to each other if they share a similar edge. You can set the minimum distance between two vertices required to connect two edges by using :ref:`NavigationServer2D.map_set_edge_connection_margin()<class_NavigationServer2D_method_map_set_edge_connection_margin>`.
|
|
|
|
\ **Note:** Overlapping two regions' navigation polygons is not enough for connecting two regions. They must share a similar edge.
|
|
|
|
The pathfinding cost of entering a region from another region can be controlled with the :ref:`enter_cost<class_NavigationRegion2D_property_enter_cost>` value.
|
|
|
|
\ **Note:** This value is not added to the path cost when the start position is already inside this region.
|
|
|
|
The pathfinding cost of traveling distances inside this region can be controlled with the :ref:`travel_cost<class_NavigationRegion2D_property_travel_cost>` multiplier.
|
|
|
|
\ **Note:** This node caches changes to its properties, so if you make changes to the underlying region :ref:`RID<class_RID>` in :ref:`NavigationServer2D<class_NavigationServer2D>`, they will not be reflected in this node's properties.
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
Tutorials
|
|
---------
|
|
|
|
- :doc:`Using NavigationRegions <../tutorials/navigation/navigation_using_navigationregions>`
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
Properties
|
|
----------
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+---------------------------------------------------+-------------------------------------------------------------------------------------+----------+
|
|
| :ref:`bool<class_bool>` | :ref:`enabled<class_NavigationRegion2D_property_enabled>` | ``true`` |
|
|
+---------------------------------------------------+-------------------------------------------------------------------------------------+----------+
|
|
| :ref:`float<class_float>` | :ref:`enter_cost<class_NavigationRegion2D_property_enter_cost>` | ``0.0`` |
|
|
+---------------------------------------------------+-------------------------------------------------------------------------------------+----------+
|
|
| :ref:`int<class_int>` | :ref:`navigation_layers<class_NavigationRegion2D_property_navigation_layers>` | ``1`` |
|
|
+---------------------------------------------------+-------------------------------------------------------------------------------------+----------+
|
|
| :ref:`NavigationPolygon<class_NavigationPolygon>` | :ref:`navigation_polygon<class_NavigationRegion2D_property_navigation_polygon>` | |
|
|
+---------------------------------------------------+-------------------------------------------------------------------------------------+----------+
|
|
| :ref:`float<class_float>` | :ref:`travel_cost<class_NavigationRegion2D_property_travel_cost>` | ``1.0`` |
|
|
+---------------------------------------------------+-------------------------------------------------------------------------------------+----------+
|
|
| :ref:`bool<class_bool>` | :ref:`use_edge_connections<class_NavigationRegion2D_property_use_edge_connections>` | ``true`` |
|
|
+---------------------------------------------------+-------------------------------------------------------------------------------------+----------+
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
Methods
|
|
-------
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`bake_navigation_polygon<class_NavigationRegion2D_method_bake_navigation_polygon>`\ (\ on_thread\: :ref:`bool<class_bool>` = true\ ) |
|
|
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Rect2<class_Rect2>` | :ref:`get_bounds<class_NavigationRegion2D_method_get_bounds>`\ (\ ) |const| |
|
|
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`get_navigation_layer_value<class_NavigationRegion2D_method_get_navigation_layer_value>`\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| |
|
|
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`RID<class_RID>` | :ref:`get_navigation_map<class_NavigationRegion2D_method_get_navigation_map>`\ (\ ) |const| |
|
|
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`RID<class_RID>` | :ref:`get_region_rid<class_NavigationRegion2D_method_get_region_rid>`\ (\ ) |const| |
|
|
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`RID<class_RID>` | :ref:`get_rid<class_NavigationRegion2D_method_get_rid>`\ (\ ) |const| |
|
|
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`is_baking<class_NavigationRegion2D_method_is_baking>`\ (\ ) |const| |
|
|
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`set_navigation_layer_value<class_NavigationRegion2D_method_set_navigation_layer_value>`\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) |
|
|
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`set_navigation_map<class_NavigationRegion2D_method_set_navigation_map>`\ (\ navigation_map\: :ref:`RID<class_RID>`\ ) |
|
|
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Signals
|
|
-------
|
|
|
|
.. _class_NavigationRegion2D_signal_bake_finished:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**bake_finished**\ (\ ) :ref:`🔗<class_NavigationRegion2D_signal_bake_finished>`
|
|
|
|
Emitted when a navigation polygon bake operation is completed.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_signal_navigation_polygon_changed:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**navigation_polygon_changed**\ (\ ) :ref:`🔗<class_NavigationRegion2D_signal_navigation_polygon_changed>`
|
|
|
|
Emitted when the used navigation polygon is replaced or changes to the internals of the current navigation polygon are committed.
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Property Descriptions
|
|
---------------------
|
|
|
|
.. _class_NavigationRegion2D_property_enabled:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **enabled** = ``true`` :ref:`🔗<class_NavigationRegion2D_property_enabled>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **is_enabled**\ (\ )
|
|
|
|
Determines if the **NavigationRegion2D** is enabled or disabled.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_property_enter_cost:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`float<class_float>` **enter_cost** = ``0.0`` :ref:`🔗<class_NavigationRegion2D_property_enter_cost>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_enter_cost**\ (\ value\: :ref:`float<class_float>`\ )
|
|
- :ref:`float<class_float>` **get_enter_cost**\ (\ )
|
|
|
|
When pathfinding enters this region's navigation mesh from another regions navigation mesh the :ref:`enter_cost<class_NavigationRegion2D_property_enter_cost>` value is added to the path distance for determining the shortest path.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_property_navigation_layers:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`int<class_int>` **navigation_layers** = ``1`` :ref:`🔗<class_NavigationRegion2D_property_navigation_layers>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_navigation_layers**\ (\ value\: :ref:`int<class_int>`\ )
|
|
- :ref:`int<class_int>` **get_navigation_layers**\ (\ )
|
|
|
|
A bitfield determining all navigation layers the region belongs to. These navigation layers can be checked upon when requesting a path with :ref:`NavigationServer2D.map_get_path()<class_NavigationServer2D_method_map_get_path>`.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_property_navigation_polygon:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`NavigationPolygon<class_NavigationPolygon>` **navigation_polygon** :ref:`🔗<class_NavigationRegion2D_property_navigation_polygon>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_navigation_polygon**\ (\ value\: :ref:`NavigationPolygon<class_NavigationPolygon>`\ )
|
|
- :ref:`NavigationPolygon<class_NavigationPolygon>` **get_navigation_polygon**\ (\ )
|
|
|
|
The :ref:`NavigationPolygon<class_NavigationPolygon>` resource to use.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_property_travel_cost:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`float<class_float>` **travel_cost** = ``1.0`` :ref:`🔗<class_NavigationRegion2D_property_travel_cost>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_travel_cost**\ (\ value\: :ref:`float<class_float>`\ )
|
|
- :ref:`float<class_float>` **get_travel_cost**\ (\ )
|
|
|
|
When pathfinding moves inside this region's navigation mesh the traveled distances are multiplied with :ref:`travel_cost<class_NavigationRegion2D_property_travel_cost>` for determining the shortest path.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_property_use_edge_connections:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **use_edge_connections** = ``true`` :ref:`🔗<class_NavigationRegion2D_property_use_edge_connections>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_use_edge_connections**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **get_use_edge_connections**\ (\ )
|
|
|
|
If enabled the navigation region will use edge connections to connect with other navigation regions within proximity of the navigation map edge connection margin.
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_NavigationRegion2D_method_bake_navigation_polygon:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **bake_navigation_polygon**\ (\ on_thread\: :ref:`bool<class_bool>` = true\ ) :ref:`🔗<class_NavigationRegion2D_method_bake_navigation_polygon>`
|
|
|
|
Bakes the :ref:`NavigationPolygon<class_NavigationPolygon>`. If ``on_thread`` is set to ``true`` (default), the baking is done on a separate thread.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_method_get_bounds:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Rect2<class_Rect2>` **get_bounds**\ (\ ) |const| :ref:`🔗<class_NavigationRegion2D_method_get_bounds>`
|
|
|
|
Returns the axis-aligned rectangle for the region's transformed navigation mesh.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_method_get_navigation_layer_value:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **get_navigation_layer_value**\ (\ layer_number\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_NavigationRegion2D_method_get_navigation_layer_value>`
|
|
|
|
Returns whether or not the specified layer of the :ref:`navigation_layers<class_NavigationRegion2D_property_navigation_layers>` bitmask is enabled, given a ``layer_number`` between 1 and 32.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_method_get_navigation_map:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`RID<class_RID>` **get_navigation_map**\ (\ ) |const| :ref:`🔗<class_NavigationRegion2D_method_get_navigation_map>`
|
|
|
|
Returns the current navigation map :ref:`RID<class_RID>` used by this region.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_method_get_region_rid:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`RID<class_RID>` **get_region_rid**\ (\ ) |const| :ref:`🔗<class_NavigationRegion2D_method_get_region_rid>`
|
|
|
|
**Deprecated:** Use :ref:`get_rid()<class_NavigationRegion2D_method_get_rid>` instead.
|
|
|
|
Returns the :ref:`RID<class_RID>` of this region on the :ref:`NavigationServer2D<class_NavigationServer2D>`.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_method_get_rid:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`RID<class_RID>` **get_rid**\ (\ ) |const| :ref:`🔗<class_NavigationRegion2D_method_get_rid>`
|
|
|
|
Returns the :ref:`RID<class_RID>` of this region on the :ref:`NavigationServer2D<class_NavigationServer2D>`. Combined with :ref:`NavigationServer2D.map_get_closest_point_owner()<class_NavigationServer2D_method_map_get_closest_point_owner>` can be used to identify the **NavigationRegion2D** closest to a point on the merged navigation map.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_method_is_baking:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`bool<class_bool>` **is_baking**\ (\ ) |const| :ref:`🔗<class_NavigationRegion2D_method_is_baking>`
|
|
|
|
Returns ``true`` when the :ref:`NavigationPolygon<class_NavigationPolygon>` is being baked on a background thread.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_method_set_navigation_layer_value:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **set_navigation_layer_value**\ (\ layer_number\: :ref:`int<class_int>`, value\: :ref:`bool<class_bool>`\ ) :ref:`🔗<class_NavigationRegion2D_method_set_navigation_layer_value>`
|
|
|
|
Based on ``value``, enables or disables the specified layer in the :ref:`navigation_layers<class_NavigationRegion2D_property_navigation_layers>` bitmask, given a ``layer_number`` between 1 and 32.
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_method_set_navigation_map:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **set_navigation_map**\ (\ navigation_map\: :ref:`RID<class_RID>`\ ) :ref:`🔗<class_NavigationRegion2D_method_set_navigation_map>`
|
|
|
|
Sets the :ref:`RID<class_RID>` of the navigation map this region should use. By default the region will automatically join the :ref:`World2D<class_World2D>` default navigation map so this function is only required to override the default map.
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
|
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
|
|
.. |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.)`
|
|
.. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
|
|
.. |void| replace:: :abbr:`void (No return value.)`
|