Does anyone know why this error message is ?

Parent node is busy setting up children, add_child() failed. Consider using add_child.call_deferred(child) instead.
scene/main/window.cpp:1658 - Condition "!is_inside_tree()" is true.

  • Toxe replied to this.

    Are you trying to add a child to the tree in ready function?

    @export var prefab : PackedScene
    
    func _ready() -> void:
    	var instance = prefab.instantiate()
    	get_tree().root.add_child(instance)

    From what I know a scenetree is locked until ready is called on all child nodes.
    Not sure if this is also true for adding children to a node that is not a scenetree.
    However, call_deferred delays the called function until the next frame (where in my example ready is called on

    Can somebody confirm this or has more details on this? I'd like to know more about this.

    I've found the problem. In the editor settings, i've checked a checkbox called "save on focus lost", and after googling a lot, i've found the issue. So i've nchecked it and now everything is fine.
    What is worrying though is that this problem is still persisting (it has been discovered in Godot 4.0)

      Yeah exactly ! And I haven't noticed any changes in the behaviour of my game.