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.
In the editor you can add nodes to other scenes after opening them in the editor.
When the other scene is within the scene tree or instantiated, then you can add nodes with the Node.add_child()
function.
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.
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.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.