system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
qdmyxwlhx |
print(pickable)
pickable.get_parent().remove_child(pickable)
print(pickable)
add_child(pickable)
pickable is the child l want to change his parent. But after call the remove_child, pickable become null. Log shows like:
pickaxe:<RigidBody2D#27078427832>
<null>
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
system
2
|
|
|
|
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.