after remove_child() the child become null?

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

pickable is the child l want to change his parent. But after call the remove_child, pickable become null. Log shows like:


can anyone help me, thanks

What happens if you re-add it? It might be because it’s briefly an orphan.

SteveSmith | 2022-12-01 18:51

:bust_in_silhouette: Reply From: Gluon

You want to use move_child not remove_child.

Documentation is here, Node — Godot Engine (stable) documentation in English

thanks, but not help. The script node and the pickable node have same parent, and l want the pickable to become current script node’s child.

And the main question is this: why remove_child() will make pickable node null? So strange

qdmyxwlhx | 2022-12-02 04:11

The remove node will set the owner of the removed Node (or its descendants) to be null, if that owner is no longer a parent or ancestor.

Gluon | 2022-12-02 10:01