Problems removing and adding nodes

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Not_a_Robot
:warning: Old Version Published before Godot 3 was released.

So, here we are!

I have the following structure:

-Panel
--Control_0
---Button
---TextureFrame
--Control_1
---Button
---TextureFrame
--Control_2
---Button
---TextureFrame
--Control_3
---Button
---TextureFrame
--Control_4
---Button
---TextureFrame

And I try to reorganize it like

-Panel
--Control_0
---Button
---TextureFrame
---Control_1
--------Button
--------TextureFrame
---Control_2
--------Button
--------TextureFrame
--------Control_3
-----------Button
-----------TextureFrame
-----------Control_4
-------------------Button
-------------------TextureFrame

What I do is:

var my_node = get_node( "path" ); 
remove_child( my_node ); 
new_parent.add_child( my_node )

Why when doing “new_parent.add_child(my_node)” the children of my_node are not visible? How can I make the TextureFrame and the Button appear again?

Thank you in advance, I don’t really know how to debug this issue.

EDIT: I found that the nodes appear actually, but they are moved to places like 3478,6102

What is happening? I don’t modify their position at all

I guess Control_3 and Control_4 are located relative to Control_2 node.
Try to reset Control_3 and Control_4 position by set_pos(Vector2(0,0))

volzhs | 2016-07-15 17:10

Ok, FINALLY! Thank you volzhs!
What you said helped me to find the solution! I set their global positions to the same position as their parent and done!

Thank you for your help! I didn’t think about that.

Not_a_Robot | 2016-07-15 17:26

:bust_in_silhouette: Reply From: volzhs

I guess Control_3 and Control_4 are located relative to Control_2 node.
Try to reset Control_3 and Control_4 position by set_pos(Vector2(0,0))

from comment