0 votes

How would one add a node back into the tree after it has been removed with something like queuefree or removechild?

in Engine by (12 points)

1 Answer

0 votes

A node which is freed with queue_free() is no more. There's no zombie virus that'd bring that back. But you could create & set & add_child() a totally new instance of that node class if that makes sense. (Or load it from a scene)

remove_child() (Called by the parent of that node) usually is the method of choice to remove a node temporarily from the tree. And adding that node back to the tree is simply done by calling add_child() from some parent node where you want it to hook in.

The docs have a little code sample that demonstrates unlinking a node and adding it again to another node:
https://docs.godotengine.org/en/latest/classes/class_node.html#class-node-method-add-child

by (3,298 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.