It seems that label_3d is being referenced (successfully) in the setter function “before” it is declared in the code below it. Does this not matter, is it all considered simultaneous outside of a function?
Hi @Bill_Leonard ,
The way I understand it is that we initialize the current_health variable which will probably receive a default value of Null (this I’m not sure how GDScript handles it).
Inside current_health we have a function that is only called when we assigned for example max_health in the _ready() function
so it would work because @onready runs before the _ready() explained here in the docs so lable_3d will be assigned a value before it is called in the _ready() function.
Please keep in mind that I’m only learning and my logic can be totally wrong.
yea the @onready is a funny one, but super handy if needing to reference a node, but the tree loading order is not in the right order to do so.
i believe it declares the variable, but delays the setting of the variable value until the node/script it refers to has fully entered the scene tree.
bit of a little read for more info as well.
< [Answered] What is the onready keyword in Godot? (dragonflydb.io)>
This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.