How to use duplicate() function?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By IndigoGames

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

:bust_in_silhouette: Reply From: jgodfrey

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:

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.

1 Like