Home / Godot / G15

Godot error: Can't add child '%s' to '%s', already has a parent '%s'. — cause and fix

Adding a node that already has a parent to another node: remove_child was skipped when mov

ID
G15
Engine
Godot
Verification
源码原文(scene/main/node.cpp:1717)
Frequency
未公开

Original message (verbatim)

Can't add child '%s' to '%s', already has a parent '%s'.

Placeholders such as %s / %d are kept verbatim from the engine source and are not replaced with concrete values.

Trigger

Adding a node that already has a parent to another node: remove_child was skipped when moving it in the tree, or an instance already attached in the editor was reused.

Typical cause

add_child checks that child->data.parent is non-null and rejects the operation; a node can have only one parent at a time.

Step-by-step fix

  1. Before moving a node, remove_child it from the old parent, then attach it to the new one.
  2. Instantiate separate copies when the node is needed in several places; do not reuse one in-tree instance.
  3. Do not drag an editor-attached node under another parent.

Source links

Per-entry sources and capture date are listed at /sources#G15.

Related errors

Related Godot errors

Need an offline quick-reference checklist?

Atlas error library Pro pack: 123 error references (110 single + 13 merged) plus a quick-fix guide, $19 one-time purchase, delivered as electronic files.

View Pro pack / order

Back to the all-errors index Checkout and buy the Pro pack — $19.00