+1 vote

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

in Engine by (75 points)

1 Answer

+6 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:


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 (16,806 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 Frequently asked questions and 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 [email protected] with your username.