This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+5 votes

I got a Godot 4.0 unstable build off of today. I found that some keywords don't work. Mainly, what do you do in the place of export, and onready?

in Engine by (52 points)

3 Answers

+7 votes

@export and @onready. It would be nice if the documentation for 4.0 was finished.

by (92 points)

How do you use it? To export a Node3D variable, what do you do?
I tried this:
@export(Node3D) var follow, but It didn't work

I also tried doing @export var follow: Node3D, @export var follow: Node3D =, @export var follow: Node3D = null, and @export var follow =

Unfortunately, there are still a lot of bugs:

+3 votes

For normal variables:

@export var health : int

NodePath export has been changed to this:

@export_node_path(Resource) var resource_name
by (83 points)

Thanks! This is what I was searching for. Where did you get the information about @exportnodepath if you don't mind me asking?

sadly you can't add :Array to an @exportnodepath

@export_node_path(Marker2D) var waypoints: Array

*this wouldnt work..

But you can do in fact.

@export var waypoints: Array

Then you get a NIL Entry, you can change the size of the array and with a click on the PEN, you can define what kind of Node it should be.. There you can select node_path and select your desired nodes. But doesnt work anymore in one script line..

Took me ages to figure it out as there is still no documentation for this.

0 votes

Since Godot 4.0, nodes can be directly exported as properties in a script without having to use NodePaths

# Allows any node.
@export var node: Node

# Allows any node that inherits from BaseButton.
# Custom classes declared with `class_name` can also be used.
@export var some_button: BaseButton
by (72 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.