change parent

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ramazan

I know this question has been asked a lot but I couldn’t find a solution.


Let “node_one” be a child of “node_two”

command line in “Main_node”
i want to do it from there

“I couldn’t do it for hours. My brain stopped”

:bust_in_silhouette: Reply From: DaddyMonster

This should hopefully do the trick:

var n1 = $node_one

EDIT: Fixed silly mistake.

The method “remove_node” isn’t declared in the current class

godot 3.4.4

i did it before but i lost the sample code

ramazan | 2022-07-18 12:52

Oh, silly me, it’s remove_child()sorry about that buddy.

DaddyMonster | 2022-07-18 12:58

two error

E 0:00:06.815 remove_child: Cannot remove child node ‘node_one’ as it is not a child of this node.

E 0:00:06.815 add_child: Can’t add child ‘node_one’ to ‘node_two’, already has a parent ‘node_two’.

but it works. Could the error be elsewhere?

ramazan | 2022-07-18 13:09

I just tested it and it works fine. You’re not calling it more than once are you?

DaddyMonster | 2022-07-18 13:24

I hope so :slight_smile:

thank you .
let me check

How many hours have I been struggling? The problem is as you said. signal was working 2 times :slight_smile: :slight_smile:

ramazan | 2022-07-18 13:34