Hello,
Regarding the “Create as Child” option in the object creation settings, even when selected, the object does not appear to be nested under the parent object (e.g., it does not follow the parent). Could you please clarify the intended behavior for this option?
I attached a script to a GameObject that was generated as a child node and attempted to trace its parent hierarchy. Even with the option toggled on or off, the grandparent of the object (where the immediate parent is the GameObject to which the script was attached, and the grandparent is expected to be the generation source) was ObjectRoot. Tracing further up did not reveal the original generating object.
extends Node2D
# On initialization, traverse all parent nodes from self to the main scene root and output their names and classes.
func _ready() -> void:
# Get the root node of the main scene
var scene_root: Node = get_tree().get_current_scene()
# Start from this node
var node: Node = self
# Continue traversing up the parent chain
while node.get_parent() != null:
# Move to the parent node
node = node.get_parent()
# Output the node name and class
print("[Ancestor] %s (Type: %s)" % [node.name, node.get_class()])
# Exit if the main scene root is reached
if node == scene_root:
break
Thank you for your time and assistance.