4 ms·
How do you remove objects if you don't queue free them? Just remove them from the tree?
by tpxl 4y ago
How do you remove objects if you don't queue free them? Just remove them from the tree?
- b33j0r 4y agoYes, or they are free’d automatically as the parent is free’d recursively. If you have called `add_child` on a node you created dynamically, godot will handle its lifecycle from there. If you don’t add a dynamically-created node to the tree, you are responsible for `free`. That almost never comes up, because I eventually figure out how to decompose everything into a tree Node, or! A Resource. Resources are managed in a separate memory pool, and don’t need to be added to the tree for godot to take care of it. Go ahead, you just try and `free` a resource! ;)
- tpxl 4y agoDamn, I didn't know that. Time to remove queue_free from my project :)
- benjaminjackman 4y agoIn the docs for Node.remove_child(Node node)[1] it says "Removes a child node. The node is NOT deleted and must be deleted manually." Do you still have to queue_free the top node that was removed from the tree, or else how is it being deleted. Or is there a different method to call for removing it from the tree. BTW: I really like the `_init` / `_enter_tree` / `_ready` / `_exit_tree` lifecycle as was described. 1:https://docs.godotengine.org/en/stable/classes/class_node.html#class-node-method-remove-child https://docs.godotengine.org/en/stable/classes/class_node.ht...
- lewispollard 4y agoqueue_free removes the node from the tree and frees it. remove_child just deactivates it, but keeps it around in memory for later.