mirror of
https://github.com/stan220/godot-docs.git
synced 2026-09-08 17:28:58 +00:00
168 lines
9.0 KiB
ReStructuredText
168 lines
9.0 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
|
|
==================
|
|
|
|
**Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
|
|
|
A region of the 2D navigation map.
|
|
|
|
Description
|
|
-----------
|
|
|
|
A region of the navigation map. It tells the :ref:`NavigationServer2D<class_NavigationServer2D>` what can be navigated and what cannot, based on its :ref:`NavigationPolygon<class_NavigationPolygon>` resource.
|
|
|
|
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' polygons is not enough for connecting two regions. They must share a similar edge.
|
|
|
|
The pathfinding cost of entering this 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.
|
|
|
|
Properties
|
|
----------
|
|
|
|
+---------------------------------------------------+-------------------------------------------------------------------------------+----------+
|
|
| :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:`navpoly<class_NavigationRegion2D_property_navpoly>` | |
|
|
+---------------------------------------------------+-------------------------------------------------------------------------------+----------+
|
|
| :ref:`float<class_float>` | :ref:`travel_cost<class_NavigationRegion2D_property_travel_cost>` | ``1.0`` |
|
|
+---------------------------------------------------+-------------------------------------------------------------------------------+----------+
|
|
|
|
Methods
|
|
-------
|
|
|
|
+-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`get_navigation_layer_value<class_NavigationRegion2D_method_get_navigation_layer_value>` **(** :ref:`int<class_int>` layer_number **)** |const| |
|
|
+-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`RID<class_RID>` | :ref:`get_region_rid<class_NavigationRegion2D_method_get_region_rid>` **(** **)** |const| |
|
|
+-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_navigation_layer_value<class_NavigationRegion2D_method_set_navigation_layer_value>` **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` value **)** |
|
|
+-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Property Descriptions
|
|
---------------------
|
|
|
|
.. _class_NavigationRegion2D_property_enabled:
|
|
|
|
- :ref:`bool<class_bool>` **enabled**
|
|
|
|
+-----------+--------------------+
|
|
| *Default* | ``true`` |
|
|
+-----------+--------------------+
|
|
| *Setter* | set_enabled(value) |
|
|
+-----------+--------------------+
|
|
| *Getter* | is_enabled() |
|
|
+-----------+--------------------+
|
|
|
|
Determines if the ``NavigationRegion2D`` is enabled or disabled.
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_property_enter_cost:
|
|
|
|
- :ref:`float<class_float>` **enter_cost**
|
|
|
|
+-----------+-----------------------+
|
|
| *Default* | ``0.0`` |
|
|
+-----------+-----------------------+
|
|
| *Setter* | set_enter_cost(value) |
|
|
+-----------+-----------------------+
|
|
| *Getter* | get_enter_cost() |
|
|
+-----------+-----------------------+
|
|
|
|
When pathfinding enters this region's navmesh from another regions navmesh the ``enter_cost`` value is added to the path distance for determining the shortest path.
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_property_navigation_layers:
|
|
|
|
- :ref:`int<class_int>` **navigation_layers**
|
|
|
|
+-----------+------------------------------+
|
|
| *Default* | ``1`` |
|
|
+-----------+------------------------------+
|
|
| *Setter* | set_navigation_layers(value) |
|
|
+-----------+------------------------------+
|
|
| *Getter* | 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>`.
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_property_navpoly:
|
|
|
|
- :ref:`NavigationPolygon<class_NavigationPolygon>` **navpoly**
|
|
|
|
+----------+-------------------------------+
|
|
| *Setter* | set_navigation_polygon(value) |
|
|
+----------+-------------------------------+
|
|
| *Getter* | get_navigation_polygon() |
|
|
+----------+-------------------------------+
|
|
|
|
The :ref:`NavigationPolygon<class_NavigationPolygon>` resource to use.
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_property_travel_cost:
|
|
|
|
- :ref:`float<class_float>` **travel_cost**
|
|
|
|
+-----------+------------------------+
|
|
| *Default* | ``1.0`` |
|
|
+-----------+------------------------+
|
|
| *Setter* | set_travel_cost(value) |
|
|
+-----------+------------------------+
|
|
| *Getter* | get_travel_cost() |
|
|
+-----------+------------------------+
|
|
|
|
When pathfinding moves inside this region's navmesh the traveled distances are multiplied with ``travel_cost`` for determining the shortest path.
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_NavigationRegion2D_method_get_navigation_layer_value:
|
|
|
|
- :ref:`bool<class_bool>` **get_navigation_layer_value** **(** :ref:`int<class_int>` layer_number **)** |const|
|
|
|
|
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.
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_method_get_region_rid:
|
|
|
|
- :ref:`RID<class_RID>` **get_region_rid** **(** **)** |const|
|
|
|
|
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.
|
|
|
|
----
|
|
|
|
.. _class_NavigationRegion2D_method_set_navigation_layer_value:
|
|
|
|
- void **set_navigation_layer_value** **(** :ref:`int<class_int>` layer_number, :ref:`bool<class_bool>` 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.
|
|
|
|
.. |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.)`
|