0 votes

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

in Engine by (73 points)

1 Answer

+4 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.

by (10,896 points)
selected by
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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.