0 votes

I made a scene and added already a lot of stuff to it but i realize i forgot my rigidbody2d and i can't reparent a parent so i want to just move the children to my rigidbody2d but i dont know how
Pls help

asked Oct 28, 2017 in Engine by Newby (383 points)

1 Answer

+1 vote

In the editor you can right click and Change Type for the parent's Node type if that is easiest.

To move the children, just create the new parent node, select all the children and drag them into the new node. From there if you want that parent to be a root of the scene, you can right click and Save Branch as Scene.

If you're talking about in code, you have to remove the child from the parent first, then add to the new parent.

Something like:

var parent = self
var child = get_node("child_to_move")

var new_parent = get_parent().get_node("new_parent")

parent.remove_child(child)
new_parent.add_child(child)
answered Oct 28, 2017 by avencherus (4,835 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 How to use this Q&A? before posting your first questions.