Skip to content

Commit 4b089d5

Browse files
authored
Merge pull request godotengine#7495 from smix8/doc_navigationobstacle_api_4.x
Update NavigationObstacle API doc
2 parents 8d5eeed + cf2db62 commit 4b089d5

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tutorials/navigation/navigation_using_navigationobstacles.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ For static use an array of ``vertices`` is required.
6161
.. tabs::
6262
.. code-tab:: gdscript GDScript
6363

64-
extends Node2D
64+
# For 2D
65+
6566
# create a new "obstacle" and place it on the default navigation map.
6667
var new_obstacle_rid: RID = NavigationServer2D.obstacle_create()
6768
var default_2d_map_rid: RID = get_world_2d().get_navigation_map()
@@ -76,10 +77,14 @@ For static use an array of ``vertices`` is required.
7677
var outline = PackedVector2Array([Vector2(-100, -100), Vector2(100, -100), Vector2(100, 100), Vector2(-100, 100)])
7778
NavigationServer2D.obstacle_set_vertices(new_obstacle_rid, outline)
7879

80+
# Enable the obstacle.
81+
NavigationServer2D.obstacle_set_avoidance_enabled(new_obstacle_rid, true)
82+
7983
.. tabs::
8084
.. code-tab:: gdscript GDScript
8185

82-
extends Node3D
86+
# For 3D
87+
8388
# Create a new "obstacle" and place it on the default navigation map.
8489
var new_obstacle_rid: RID = NavigationServer3D.obstacle_create()
8590
var default_3d_map_rid: RID = get_world_3d().get_navigation_map()
@@ -93,3 +98,8 @@ For static use an array of ``vertices`` is required.
9398
# Use obstacle static by adding a square that pushes agents out.
9499
var outline = PackedVector3Array([Vector3(-5, 0, -5), Vector3(5, 0, -5), Vector3(5, 0, 5), Vector3(-5, 0, 5)])
95100
NavigationServer3D.obstacle_set_vertices(new_obstacle_rid, outline)
101+
# Set the obstacle height on the y-axis.
102+
NavigationServer3D.obstacle_set_height(new_obstacle_rid, 1.0)
103+
104+
# Enable the obstacle.
105+
NavigationServer3D.obstacle_set_avoidance_enabled(new_obstacle_rid, true)

0 commit comments

Comments
 (0)