mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2026-01-04 10:09:56 +03:00
350 lines
18 KiB
ReStructuredText
350 lines
18 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. _class_NavigationRegion2D:
|
|
|
|
NavigationRegion2D
|
|
==================
|
|
|
|
**Sperimentale:** This class may be changed or removed in future versions.
|
|
|
|
**Eredita:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
|
|
|
Una regione 2D attraversabile che gli :ref:`NavigationAgent2D<class_NavigationAgent2D>` possono utilizzare per la ricerca del percorso.
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
Descrizione
|
|
----------------------
|
|
|
|
Una regione 2D attraversabile basata su un :ref:`NavigationPolygon<class_NavigationPolygon>` che i :ref:`NavigationAgent2D<class_NavigationAgent2D>` possono utilizzare per la ricerca del percorso.
|
|
|
|
Due regioni possono essere collegate tra loro se condividono un bordo simile. Puoi impostare la distanza minima tra due vertici richiesta per collegare due bordi tramite :ref:`NavigationServer2D.map_set_edge_connection_margin()<class_NavigationServer2D_method_map_set_edge_connection_margin>`.
|
|
|
|
\ **Nota:** Sovrapporre i poligoni di navigazione di due regioni non è abbastanza per collegare due regioni. Devono condividere un bordo simile.
|
|
|
|
Il costo della ricerca del percorso per entrare in una regione da un'altra regione può essere controllato con la proprietà :ref:`enter_cost<class_NavigationRegion2D_property_enter_cost>`.
|
|
|
|
\ **Nota:** Questa proprietà non viene aggiunta al costo del percorso quando la posizione di partenza è già all'interno di questa regione.
|
|
|
|
Il costo della ricerca del percorso per percorrere distanze all'interno di questa regione può essere controllato con il moltiplicatore :ref:`travel_cost<class_NavigationRegion2D_property_travel_cost>`.
|
|
|
|
\ **Nota:** Questo nodo memorizza nella cache le modifiche apportate alle sue proprietà, quindi se si apportano modifiche al :ref:`RID<class_RID>` della regione sottostante nel :ref:`NavigationServer2D<class_NavigationServer2D>`, queste non saranno riflesse nelle proprietà di questo nodo.
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
Tutorial
|
|
----------------
|
|
|
|
- :doc:`Utilizzo dei NavigationRegion <../tutorials/navigation/navigation_using_navigationregions>`
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
Proprietà
|
|
------------------
|
|
|
|
.. 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
|
|
|
|
Metodi
|
|
------------
|
|
|
|
.. 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
|
|
|
|
Segnali
|
|
--------------
|
|
|
|
.. _class_NavigationRegion2D_signal_bake_finished:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**bake_finished**\ (\ ) :ref:`🔗<class_NavigationRegion2D_signal_bake_finished>`
|
|
|
|
Emesso quando un'operazione di preparazione del poligono di navigazione viene completata.
|
|
|
|
.. 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>`
|
|
|
|
Emesso quando il poligono di navigazione utilizzato viene sostituito oppure vengono modificati i componenti interni del poligono di navigazione attuale.
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Descrizioni delle proprietà
|
|
------------------------------------------------------
|
|
|
|
.. _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**\ (\ )
|
|
|
|
Determina se il **NavigationRegion2D** è abilitato o disabilitato.
|
|
|
|
.. 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**\ (\ )
|
|
|
|
Quando la ricerca del percorso entra nella mesh di navigazione di questa regione dalla mesh di navigazione di un'altra regione, il valore di :ref:`enter_cost<class_NavigationRegion2D_property_enter_cost>` viene aggiunto alla distanza del percorso per determinare il percorso più breve.
|
|
|
|
.. 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**\ (\ )
|
|
|
|
Un campo di bit che determina tutti gli strati di navigazione a cui appartiene la regione. Questi strati di navigazione possono essere controllati quando si richiede un percorso con :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**\ (\ )
|
|
|
|
La risorsa :ref:`NavigationPolygon<class_NavigationPolygon>` da utilizzare.
|
|
|
|
.. 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**\ (\ )
|
|
|
|
Quando la ricerca del percorso si muove all'interno della mesh di navigazione di questa regione, le distanze percorse vengono moltiplicate per il valore di :ref:`travel_cost<class_NavigationRegion2D_property_travel_cost>` per determinare il percorso più breve.
|
|
|
|
.. 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**\ (\ )
|
|
|
|
Se abilitato, la regione di navigazione utilizzerà le connessioni ai bordi per connettersi ad altre regioni di navigazione in prossimità del margine di connessione ai bordi della mappa di navigazione.
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
Descrizioni dei metodi
|
|
--------------------------------------------
|
|
|
|
.. _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>`
|
|
|
|
Prepara il :ref:`NavigationPolygon<class_NavigationPolygon>`. Se ``on_thread`` è impostato su ``true`` (predefinito), la preparazione viene eseguita su un thread separato.
|
|
|
|
.. 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>`
|
|
|
|
Restituisce il rettangolo allineato agli assi per la mesh trasformata di navigazione della regione.
|
|
|
|
.. 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>`
|
|
|
|
Restituisce se lo strato specificato della maschera di bit :ref:`navigation_layers<class_NavigationRegion2D_property_navigation_layers>` è abilitato o meno, fornito un ``layer_number`` tra 1 e 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>`
|
|
|
|
Restituisce il :ref:`RID<class_RID>` attuale della mappa di navigazione utilizzata da questa regione.
|
|
|
|
.. 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>`
|
|
|
|
**Deprecato:** Use :ref:`get_rid()<class_NavigationRegion2D_method_get_rid>` instead.
|
|
|
|
Restituisce il :ref:`RID<class_RID>` di questa regione sul :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>`
|
|
|
|
Restituisce il :ref:`RID<class_RID>` di questa regione sul :ref:`NavigationServer2D<class_NavigationServer2D>`. In combinazione con :ref:`NavigationServer2D.map_get_closest_point_owner()<class_NavigationServer2D_method_map_get_closest_point_owner>`, questo metodo può essere utilizzato per identificare il **NavigationRegion2D** più vicino a un punto sulla mappa unita di navigazione.
|
|
|
|
.. 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>`
|
|
|
|
Restituisce ``true`` quando il :ref:`NavigationPolygon<class_NavigationPolygon>` è in fase di preparazione su un thread in background.
|
|
|
|
.. 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>`
|
|
|
|
In base al ``value``, abilita o disabilita lo strato specificato nella maschera di bit :ref:`navigation_layers<class_NavigationRegion2D_property_navigation_layers>`, fornito un ``layer_number`` compreso tra 1 e 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>`
|
|
|
|
Imposta il :ref:`RID<class_RID>` della mappa di navigazione che questa regione dovrebbe usare. Per impostazione predefinita, la regione si unirà automaticamente alla mappa predefinita di navigazione del :ref:`World2D<class_World2D>`, quindi questa funzione è necessaria solo per sovrascrivere la mappa predefinita.
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (Questo metodo dovrebbe solitamente essere sovrascritto dall'utente per aver un effetto.)`
|
|
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
|
|
.. |const| replace:: :abbr:`const (Questo metodo non ha effetti collaterali. Non modifica alcuna variabile appartenente all'istanza.)`
|
|
.. |vararg| replace:: :abbr:`vararg (Questo metodo accetta qualsiasi numero di argomenti oltre a quelli descritti qui.)`
|
|
.. |constructor| replace:: :abbr:`constructor (Questo metodo è utilizzato per creare un tipo.)`
|
|
.. |static| replace:: :abbr:`static (Questo metodo non necessita di alcun'istanza per essere chiamato, quindi può essere chiamato direttamente usando il nome della classe.)`
|
|
.. |operator| replace:: :abbr:`operator (Questo metodo descrive un operatore valido da usare con questo tipo come operando di sinistra.)`
|
|
.. |bitfield| replace:: :abbr:`BitField (Questo valore è un intero composto da una maschera di bit dei seguenti flag.)`
|
|
.. |void| replace:: :abbr:`void (Nessun valore restituito.)`
|