Parent node is busy setting up children, add_node() failed

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

I have an error that i completely not understand, what is this?
I tried solution that this error said but call_deferred() not exist anywhere, documentation can’t search it

0:00:00:0541 - Parent node is busy setting up children, add_node() failed. Consider using call_deferred("add_child", child) instead.
---------- Type:Error Description: Parent node is busy setting up children, add_node() failed. Consider using call_deferred("add_child", child) instead.
Time: 0:00:00:0541 C Error: Condition ' data.blocked > 0 ' is true. C Source: scene\main\node.cpp:1336 C Function: Node::add_child
:bust_in_silhouette: Reply From: volzhs

it happens when adding new node by add_child() in _ready()
call_deferred is defined in Object class. (you can find it with Search Help on editor.)

so actually you can call it with any nodes.

func _ready():
    call_deferred("add_child", new_child)

i wrote "

call_deffered

" in documentation by accident :smiley:
So, when i use add_child in ready func, i always must do this call?
It is a normal practice?

Huder | 2018-05-02 19:51

I have not tried to find when it happens.
but it does not happen always.
probably, in some complicated condition.

volzhs | 2018-05-02 19:54

How do you call call_deferred on something else than the current node?

I understand that doing this :
call_deferred(“add_child”, new_child)
has the same meaning (apart from the “deferred” part, of course) as doing that :
this.addChild (new_child)

…but what would be the deferred equivalent to this :
get_tree().get_root().addChild(new_child)

jeancallisti | 2019-04-23 15:13

I know this is old, but for those who are looking for the answer to this question is to still call CallDeferred, but on the Root rather than the current node:

func _ready():
    get_tree().get_root().call_deferred("add_child", child_node)

Novithian | 2019-09-08 04:30