Topic was automatically imported from the old Question2Answer platform.
Asked By
Abdulrahman
I have a main node A and a sub node of A called “B”, the problem is when I queue_free() to node b and tries to see how many nodes in A it gives me the same number. I’m testing how many nodes inside A by using get_children() inside _physics_process(delta) function for testing purposes.
queue_free() does not delete a Node immediately so if you check children right after calling it you won’t see any change.
You may queue_free a Node and then remove it from tree
$"B".queue_free()
remove_child($"B")
At this point B will not be a child of A, although it won’t be destroyed yet.
free() function deletes a Node immediately but SceneTree is in some cases locked and no nodes can be removed from it. To make sure SceneTree isn’t locked use call_deferred