Topic was automatically imported from the old Question2Answer platform.
Asked By
Nv7-GitHub
I got a Godot 4.0 unstable build off of https://hugo.pro/projects/godot-builds/ today. I found that some keywords don’t work. Mainly, what do you do in the place of export, and onready?
@export and @onready. It would be nice if the documentation for 4.0 was finished.
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
Nv7-GitHub | 2020-10-06 00:38
I also tried doing @export var follow: Node3D, @export var follow: Node3D = Node3D.new(), @export var follow: Node3D = null, and @export var follow = Node3D.new()
Thanks! This is what I was searching for. Where did you get the information about @export_node_path if you don’t mind me asking?
Hammo | 2022-08-15 15:40
sadly you can’t add :Array to an @export_node_path
@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.
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