Home / Godot / G16

Godot error: Can't add child '%s' to '%s' as it would result in a cyclic dependency since '%s' is already a parent of '%s'. — cause and fix

Adding a child under one of its own ancestors, creating a parent-child cycle, for example

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

Original message (verbatim)

Can't add child '%s' to '%s' as it would result in a cyclic dependency since '%s' is already a parent of '%s'.

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

Trigger

Adding a child under one of its own ancestors, creating a parent-child cycle, for example attaching a parent node beneath its own child.

Typical cause

add_child uses is_ancestor_of to detect cycles; when the child is already an ancestor of the target node it refuses to avoid a loop in the scene tree.

Step-by-step fix

  1. Adjust the hierarchy so the node being added is not an ancestor of the target.
  2. Release the wrong parent-child link before re-attaching.
  3. Check the direction of dynamic node reparenting in scripts; do not attach a higher node under a lower one.

Source links

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

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