#How to copy an already instantiated scene?

1 messages · Page 1 of 1 (latest)

fleet quest
#

Basically what I want to do is have a scene saved in the script kinda like this:

var scene = preload(ScenePathOrSmth.tscn).instantiate()

And then have a line that can create a copy of that scene at any point. I would need to be able to make changes to the original scene without making changes to all of the copies too, like the values of certain variables.

#

Not quite. To clarify I want the changes to be made to the base scene during gameplay, that would change all future copies but not current copies

tired roost
#

ah, but it only works for Resource. So it can't be done.

#

ah, but node.duplicate() seems pretty deep already?

#

should work

fleet quest
#

I just tested it a bit and it seems to work perfectly

fleet quest
#

okay so I tested it some more and I found out it doesn't actually work quite how I want it

#

the way I want it work in an imaginary hypothetical, thing2's hand variable should be 99

#

but it prints 0, which is what it is by default

#

is there a way I can get around this without manually setting every variable from thing2 to be the same as thing?

tired roost
#

I doubt you can other than making it a resource, array, or dictionary.

fleet quest
#

wym by that

tired roost
#

Node just has duplicate with flags

#

Check the docs

#

But...

#

It should be at least copying direct properties.... so your example should not print 0... unless you're loading a non node

#

Or did something silly like setting hand onready

fleet quest
#

what do you mean by non node

#

okay so when I switch from hand to any other variable it works fine so there's probably just something silly I wrote in my script that's messing me up