mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-03 05:48:42 +03:00
Add C# examples to Using NavigationRegions
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Co-authored-by: Raul Santos <raulsntos@gmail.com>
This commit is contained in:
committed by
Max Hilbrunner
parent
050c9b94a9
commit
74a2c38cc4
@@ -45,12 +45,32 @@ The region RID can then be obtained from NavigationRegion Nodes with ``get_rid()
|
||||
|
||||
var navigationserver_region_rid: RID = get_rid()
|
||||
|
||||
.. code-tab:: csharp 2D C#
|
||||
|
||||
public partial class MyNavigationRegion2D : NavigationRegion2D
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
Rid navigationServerRegionRid = GetRid();
|
||||
}
|
||||
}
|
||||
|
||||
.. code-tab:: gdscript 3D GDScript
|
||||
|
||||
extends NavigationRegion3D
|
||||
|
||||
var navigationserver_region_rid: RID = get_rid()
|
||||
|
||||
.. code-tab:: csharp 3D C#
|
||||
|
||||
public partial class MyNavigationRegion3D : NavigationRegion3D
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
Rid navigationServerRegionRid = GetRid();
|
||||
}
|
||||
}
|
||||
|
||||
New regions can also be created with the NavigationServer API and added to any existing map.
|
||||
|
||||
If regions are created with the NavigationServer API directly they need to be assigned a navigation map manually.
|
||||
@@ -65,6 +85,18 @@ If regions are created with the NavigationServer API directly they need to be as
|
||||
var default_map_rid: RID = get_world_2d().get_navigation_map()
|
||||
NavigationServer2D.region_set_map(new_region_rid, default_map_rid)
|
||||
|
||||
.. code-tab:: csharp 2D C#
|
||||
|
||||
public partial class MyNode2D : Node2D
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
Rid newRegionRid = NavigationServer2D.RegionCreate();
|
||||
Rid defaultMapRid = GetWorld2D().NavigationMap;
|
||||
NavigationServer2D.RegionSetMap(newRegionRid, defaultMapRid);
|
||||
}
|
||||
}
|
||||
|
||||
.. code-tab:: gdscript 3D GDScript
|
||||
|
||||
extends Node3D
|
||||
@@ -74,6 +106,18 @@ If regions are created with the NavigationServer API directly they need to be as
|
||||
var default_map_rid: RID = get_world_3d().get_navigation_map()
|
||||
NavigationServer3D.region_set_map(new_region_rid, default_map_rid)
|
||||
|
||||
.. code-tab:: csharp 3D C#
|
||||
|
||||
public partial class MyNode3D : Node3D
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
Rid newRegionRid = NavigationServer3D.RegionCreate();
|
||||
Rid defaultMapRid = GetWorld3D().NavigationMap;
|
||||
NavigationServer3D.RegionSetMap(newRegionRid, defaultMapRid);
|
||||
}
|
||||
}
|
||||
|
||||
.. note::
|
||||
|
||||
Navigation regions can only be assigned to a single navigation map.
|
||||
|
||||
Reference in New Issue
Block a user