summaryrefslogtreecommitdiff
path: root/doc/classes/NavigationPolygon.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/classes/NavigationPolygon.xml')
-rw-r--r--doc/classes/NavigationPolygon.xml29
1 files changed, 24 insertions, 5 deletions
diff --git a/doc/classes/NavigationPolygon.xml b/doc/classes/NavigationPolygon.xml
index e75efa3b27..38921078d7 100644
--- a/doc/classes/NavigationPolygon.xml
+++ b/doc/classes/NavigationPolygon.xml
@@ -6,22 +6,41 @@
<description>
There are two ways to create polygons. Either by using the [method add_outline] method, or using the [method add_polygon] method.
Using [method add_outline]:
- [codeblock]
+ [codeblocks]
+ [gdscript]
var polygon = NavigationPolygon.new()
var outline = PackedVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
polygon.add_outline(outline)
polygon.make_polygons_from_outlines()
$NavigationRegion2D.navpoly = polygon
- [/codeblock]
+ [/gdscript]
+ [csharp]
+ var polygon = new NavigationPolygon();
+ var outline = new Vector2[] { new Vector2(0, 0), new Vector2(0, 50), new Vector2(50, 50), new Vector2(50, 0) };
+ polygon.AddOutline(outline);
+ polygon.MakePolygonsFromOutlines();
+ GetNode&lt;NavigationRegion2D&gt;("NavigationRegion2D").Navpoly = polygon;
+ [/csharp]
+ [/codeblocks]
Using [method add_polygon] and indices of the vertices array.
- [codeblock]
+ [codeblocks]
+ [gdscript]
var polygon = NavigationPolygon.new()
var vertices = PackedVector2Array([Vector2(0, 0), Vector2(0, 50), Vector2(50, 50), Vector2(50, 0)])
- polygon.set_vertices(vertices)
+ polygon.vertices = vertices
var indices = PackedInt32Array(0, 3, 1)
polygon.add_polygon(indices)
$NavigationRegion2D.navpoly = polygon
- [/codeblock]
+ [/gdscript]
+ [csharp]
+ var polygon = new NavigationPolygon();
+ var vertices = new Vector2[] { new Vector2(0, 0), new Vector2(0, 50), new Vector2(50, 50), new Vector2(50, 0) };
+ polygon.Vertices = vertices;
+ var indices = new int[] { 0, 3, 1 };
+ polygon.AddPolygon(indices);
+ GetNode&lt;NavigationRegion2D&gt;("NavigationRegion2D").Navpoly = polygon;
+ [/csharp]
+ [/codeblocks]
</description>
<tutorials>
<link title="2D Navigation Demo">https://godotengine.org/asset-library/asset/117</link>