Is there a way to add a child to another scene?

Godot Version

Godot 4

Question

Is there a way to add a child to another scene?

This is a very generic question with different answers depending on the context.

  1. In the editor you can add nodes to other scenes after opening them in the editor.

  2. When the other scene is within the scene tree or instantiated, then you can add nodes with the Node.add_child() function.

  3. If the other scene is available as a .tscn file and you want to change the content of that file, then you would have to load the scene, instantiate it, add the respective node, and save it afterwards again.

So it really depends on your context, which is not mentioned in your question.

1 Like

To add to that list, one can reparent a node like so:

node.reparent(newParent)

The node has to have a parent in the first place, obviously.