Godot: A function to change parent

Created on 7 Jul 2016  路  7Comments  路  Source: godotengine/godot

A function to change parent could be useful
Node.change_parent(ParentNode)

There is a workaround to Node.add_child(Node) then Node.quee_free() the old one, but it will loose all its instanced values.

archived discussion feature proposal core

Most helpful comment

Maybe something like detach_child would be more informative?

All 7 comments

parent_node1.remove_child(child_node)
parent_node2.add_child(child_node)

:)

Also to some extent a duplicate of #1905, so closing.

@akien-mga Ahh.. I knew it there was a dupe :smile:

See also #1943, #1949, #2657 and #3290..

Bottom line, yes adding a helper function to reparent a node would be cool, but it wouldn't automagically solve the above-mentioned issues (just see how many commits the other guys did in their PRs that did not get merged).

Haha. I think the gotcha is most people forget that if you remove the child node you can still access it and move it wherever. What I first thought was if we do remove_child that node is poofed permanently, which isn't the case. We are free to re-parent that sucker wherever we want :D

Maybe something like detach_child would be more informative?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

n-pigeon picture n-pigeon  路  3Comments

RebelliousX picture RebelliousX  路  3Comments

EdwardAngeles picture EdwardAngeles  路  3Comments

Zylann picture Zylann  路  3Comments

mefihl picture mefihl  路  3Comments