From 0c5d6868a14fb5967b897833ac7b673d8d47a393 Mon Sep 17 00:00:00 2001 From: Shawn Hardern <126725649+ShawnHardern@users.noreply.github.com> Date: Fri, 23 Aug 2024 12:58:00 +0100 Subject: [PATCH] Add C# examples to Using NavigationMaps Co-authored-by: Raul Santos --- .../navigation_using_navigationmaps.rst | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tutorials/navigation/navigation_using_navigationmaps.rst b/tutorials/navigation/navigation_using_navigationmaps.rst index 66c901625..078250d4d 100644 --- a/tutorials/navigation/navigation_using_navigationmaps.rst +++ b/tutorials/navigation/navigation_using_navigationmaps.rst @@ -33,6 +33,16 @@ The 3D default navigation map RID can be obtained with ``get_world_3d().get_navi func _ready() -> void: var default_navigation_map_rid: RID = get_world_2d().get_navigation_map() + .. code-tab:: csharp 2D C# + + public partial class MyNode2D : Node2D + { + public override void _Ready() + { + Rid defaultNavigationMapRid = GetWorld2D().NavigationMap; + } + } + .. code-tab:: gdscript 3D GDScript extends Node3D @@ -40,6 +50,16 @@ The 3D default navigation map RID can be obtained with ``get_world_3d().get_navi func _ready() -> void: var default_navigation_map_rid: RID = get_world_3d().get_navigation_map() + .. code-tab:: csharp 3D C# + + public partial class MyNode3D : Node3D + { + public override void _Ready() + { + Rid defaultNavigationMapRid = GetWorld3D().NavigationMap; + } + } + Creating new navigation maps ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -66,6 +86,17 @@ Navigation regions and avoidance agents can only be part of a single navigation var new_navigation_map: RID = NavigationServer2D.map_create() NavigationServer2D.map_set_active(new_navigation_map, true) + .. code-tab:: csharp 2D C# + + public partial class MyNode2D : Node2D + { + public override void _Ready() + { + Rid newNavigationMap = NavigationServer2D.MapCreate(); + NavigationServer2D.MapSetActive(newNavigationMap, true); + } + } + .. code-tab:: gdscript 3D GDScript extends Node3D @@ -74,6 +105,17 @@ Navigation regions and avoidance agents can only be part of a single navigation var new_navigation_map: RID = NavigationServer3D.map_create() NavigationServer3D.map_set_active(new_navigation_map, true) + .. code-tab:: csharp 3D C# + + public partial class MyNode3D : Node3D + { + public override void _Ready() + { + Rid newNavigationMap = NavigationServer3D.MapCreate(); + NavigationServer3D.MapSetActive(newNavigationMap, true); + } + } + .. note:: There is no difference between navigation maps created with the NavigationServer2D API or the NavigationServer3D API.