Godot Version
v4.2.2.stable.mono.official [15073afe3]
Question
How do I import built-in types in gdscript?
For example, I want to use a Shape2D in a script which doesn’t seem to have a definition for Shape2D.
extends Node
@export var direction: Vector2 = Vector2(0, 0)
@export var collision_shape = RectangleShape2D(Vector2(64, 64))
func get_relative_direction():
return direction \* $CobbleRoadStraight.transform
This returns the following error:
res://scenes/ConveryorArea.gd:4 - Parse Error: Function "RectangleShape2D()" not found in base self.
res://scenes/ConveryorArea.gd:4 - Parse Error: Cannot use simple "@export" annotation because the type of the initialized value can't be inferred.