Click or drag to resize

NodeAddChild Method

Adds a child node. Nodes can have any number of children, but every child must have a unique name. Child nodes are automatically deleted when the parent node is deleted, so an entire scene can be removed by deleting its topmost node.

If legible_unique_name is true, the child node will have a human-readable name based on the name of the node being instanced instead of its type.

Note: If the child node already has a parent, the function will fail. Use RemoveChild(Node) first to remove the node from its current parent. For example:

if child_node.get_parent():
    child_node.get_parent().remove_child(child_node)
add_child(child_node)

Note: If you want a child to be persisted to a PackedScene, you must set Owner in addition to calling AddChild(Node, Boolean). This is typically relevant for tool scripts and editor plugins. If AddChild(Node, Boolean) is called without setting Owner, the newly added Node will not be visible in the scene tree, though it will be visible in the 2D/3D view.

Namespace:  Godot
Assembly:  GodotSharp (in GodotSharp.dll) Version: 1.0.0
Syntax
C#
public void AddChild(
	Node node,
	bool legibleUniqueName = false
)

Parameters

node
Type: GodotNode

[Missing <param name="node"/> documentation for "M:Godot.Node.AddChild(Godot.Node,System.Boolean)"]

legibleUniqueName (Optional)
Type: SystemBoolean

[Missing <param name="legibleUniqueName"/> documentation for "M:Godot.Node.AddChild(Godot.Node,System.Boolean)"]

See Also