#Unexpected "Identifier" in class body Using the NavigationMeshes tutorial in the docs

7 messages · Page 1 of 1 (latest)

uncut kindle
#

Hello guys when I copy and pasted the "Procedual 2D NavigationMesh" tutorial code in my project it spews out this error
Line 6:Unexpected "Identifier" in class body.
Did I break something? or it is just a bug?

#

Here's the code:

extends Node2D

var new_2d_region_rid: RID = NavigationServer2D.region_create()

var default_2d_map_rid: RID = get_world_2d().get_navigation_map()
NavigationServer2D.region_set_map(new_2d_region_rid, default_2d_map_rid)

var new_navigation_polygon: NavigationPolygon = NavigationPolygon.new()
var new_outline: PackedVector2Array = PackedVector2Array([
Vector2(0.0, 0.0),
Vector2(50.0, 0.0),
Vector2(50.0, 50.0),
Vector2(0.0, 50.0),
])
new_navigation_polygon.add_outline(new_outline)
new_navigation_polygon.make_polygons_from_outlines()

NavigationServer2D.region_set_navigation_polygon(new_2d_region_rid, new_navigation_polygon)

junior echo
#

What godot version are you using?

uncut kindle
#

Godot 4.0.2

#

Sry for the late reply

junior echo
#

make this

var new_outline: PackedVector2Array = PackedVector2Array([
    Vector2(0.0, 0.0),
    Vector2(50.0, 0.0),
    Vector2(50.0, 50.0),
    Vector2(0.0, 50.0),
])```

a one-liner. there are some whitespaces in there that are messing with godot
uncut kindle
#

No I am specifically getting an error when the engine is calling NavigationServer2d