Godot Version
4.3.beta-1
Question
In my game I’d like to change a node’s parent. Right now I’m using remove_child, and add_child on the next code line, but some functionalities break when this node is freed and waiting to be added.
4.3.beta-1
In my game I’d like to change a node’s parent. Right now I’m using remove_child, and add_child on the next code line, but some functionalities break when this node is freed and waiting to be added.
There is reparent()
.
But I’m not sure if it won’t break things for you.
reparent()
shouldn’t break anything. I use it extensively.
It’s worth noting that (under the hood) reparent
is just doing remove_child
and add_child
as well. So if @AndrewGrimm had “some functionalities break” before, using this function likely won’t fix any of that.
That being said, remove_child
will also not free the node (as Andrew claimed) and if you call add_child
immediately after there should be no “waiting to be added” either. Bottom line: It would really help to know what exactly your code is doing!