Search code examples
godotgdscript

how can I use get_children() after I used queue_free() or free() on a node?


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.


Solution

  • Calling queue_free() on a node will delete it after the current frame. Try calling get_children() after the _physics_process function restarts and you'll see that the node has been removed. Calling free() will delete it immediately but it is not recommended.