1

I switched from Godot 3 to Godot 4 and was trying to make a platforming game. I need the export(Resource) function, but it no longer exists/functions in the new Godot. What's the equivalent of the function, but in Godot 4?

(language is GDScript)

100k7gm
  • 25
  • 4

1 Answers1

0

First of all, export was never a function. It was a keyword. And instead of the export keyword, Godot 4 uses the @export annotation. You can find the syntax in GDScript exports.

There are other annotations, you might do good in reading about them in the official documentation: annotations.


And second, in Godot 4 the way a variable is exported is predicated on the declared type of the variable.

So what you would write in Godot 3 like this:

export(Resource) var variable_name:Resource

In Godot 4 would be like this:

@export var variable_name:Resource

Furthermore, chances are you don't want to export as Resource but as a more specific type, except Godot 3 didn't support exporting variables a custom Resource types (build-in types were fine). However that is no longer true in Godot 4, so you can use your custom Resource type:

@export var variable_name:CustomResourceClass
Theraot
  • 31,890
  • 5
  • 57
  • 86