I have labeled a few nodes (Spatials) with the tool keyword and make changes to values of the instance in the editor. When I duplicate a node, it(s children) have default values and not edited ones. 'duplicate()' does not do something like a copy-constructor from c++ but more like a default constructor.

Is there a clean way to do this beyond saving and loading it as scene?

All that is sort of pointless if you want to modify the assembly in the editor while developing it and save it out. It is not efficient if the dev needs to duplicate a hierarchy that's subject to modification.

Even being about to save out the change so it can be loaded in a few seconds would go a long way.

Some operations are cleaner if the dev is not constantly swapping tabs and editing contexts. Something that unfortunately the editor requires. Can't have tab specific layouts so every time I want to see output or the inspected click click click click click click just to do a bunch of repetitive 'flower arranging' to be get at the data I need, over and over and over. It is mentally draining especially since on the mac if I use a browser I have to click twice on a godot because the first time I click on the app, it immediately loses focus and front.

I could implement a cloning set of calls but it's ridiculous.

I have no idea if it would work, but have you tried node_here.duplicate(Node.DUPLICATE_USE_INSTANCING)?

You could also duplicate the node and then pass the values to it in script. If you wanted to make the process a little more seamless, you could even pass the original to the duplicate and let it take the values it needs in a function. It would not be totally automatic, but it may be a decent workaround:

func duplicate_post_process(original):
	self.variable_here = original.variable_here

# then when duplicating:
var clone = node_here.duplicate()
clone.duplicate_post_process(node_here)

@TwistedTwigleg duplicate_post_process() would be the scut work I'd prefer to avoid.

The situation I have is I would like to generate or load a node hierarchy, modify and clone it with all the modifications.

@RAM thanks. Sorry all if I was testy but I rather think this issue shows up enough that it would be very nice to have a in engine solution.

At least for my application, serializing the relevant node data and constructing hierarchies from it is going to be the best solution. Duplication is seductive but also counter productive for the simple reason that is gives the illusion of a solution.

2 years later