Godot 4.0 alpha 7: How to get nodes in GDscript?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MikeMikeMike

Hi…,

I’ve opened my Godot 3.4.stable projects in Godot 4.0 alpha 7.

In GDscript my following code to get a node:

onready var ballMesh : MeshInstance = $ViewportContainer/Viewport/BallMesh

throws now this error: Unexpected “Identifier” in class body.

What to do?

Thanks

Mike

:bust_in_silhouette: Reply From: aipie

I believe the “onready” is now an annotation in gdscript2.
See GDScript reference — Godot Engine (latest) documentation in English

Basically change “onready” to “@onready

Hi aipie,

that’s it, thanks a lot

Mike

MikeMikeMike | 2022-05-06 19:47