0 votes

How to use duplicate() function? Documentation is kind of vage and i want to know how to use the DuplicateFlags.

asked Feb 7 in Engine by IndigoGames (69 points)

1 Answer

+3 votes
Best answer

I haven't used it, but it seems to be documented well enough.

The basic use is var newNode = $YourTargetNode.duplicate(DupFlags)

The DuplicateFlagsis an optional argument that defines some of the details about the duplication. Those are documented here:

https://docs.godotengine.org/en/3.2/classes/class_node.html#enum-node-duplicateflags

As documented, the default value of the argument is 15 if you don't specify it. If you look at the DuplicateFlags doc, you'll see that it's an enum, each with a unique "bit" value.

The default value of 15 is really just the all of the enum values added together (8 + 4 + 2 + 1). So, the default value duplicates everything from the target node. If you don't want to duplicate some of those things, just don't specify them in your argument.

For example, if you wanted to duplicate everything except the scripts, you'd specify a value of 11 (8 + 2 + 1) - leaving out 4, which represents script duplication.

answered Feb 7 by jgodfrey (5,296 points)
selected Feb 8 by IndigoGames
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.