-
-
Notifications
You must be signed in to change notification settings - Fork 36
Description
When this line is called, the scenes func _ready() begins. When instantiating a scenes in Godot, the properties tend to be set before add_child(someNode) is called.
In this example, the value starts as defaultValue, then it gets set to CHANGED_BY_INSPECTOR, then _ready() runs, then lastly the value gets set to changedByTrenchBroom. Usually, I would add a await owner.ready, but even that is set after the object is added.
extends Node3D
@export var testString:String = "defaultValue":
set(value):
print("set from %s to %s" % [testString,value])
testString = value
func _ready():
print("ready! testString is %s" % testString)
# await owner.ready #a common way to make sure properties are set correctly before proceding
await get_parent().ready
print("parent ready! testString is %s" % testString)
passBuilding map res://levels/tutorial/tutorial.map
set from defaultValue to CHANGED_BY_INSPECTOR
ready! testString is CHANGED_BY_INSPECTOR
set from CHANGED_BY_INSPECTOR to changedByTrenchBroom
parent ready! testString is changedByTrenchBroom
I believe if you move line 170 m_loader->add_child(instance); to after line 220 right before the return, it should behave more like what I would expect a Godot object to work. But I haven't tested this. Owner should definitely be set before adding an a child. A common way to verify a scene is fully loaded is to use await owner.ready, and this method isn't useful if owner == null.
