Instantiate - keeping the object for later


we can duplicate something with simple

Instantiate(something, something.position,something.rotation);

code. but what if we wanted to duplicate that "something" later - for example, a rocket flies-by. click (save), and after three seconds, we want to instantiate the rocket - as it was - at the moment of "click".

normally we could possibly save the "transform" at the moment of click, so that it could be referenced later,

var saved:Transform;

if(click_save) saved = transform;
(some time passes)
Instantiate(saved (...));

but no, not really, as the said "saved:Transform" would update along with the object - for example, if the rocket would crash into a wall, and lose a few objects (fixed to it previously), this, I would expect, would instantiate that broken rocket, instead of a rocket that was 'saved" at the moment of click...

if I didn't overcomplicate the explanation here.

so how to create such a "snapshot" of an object? I assume it would have to do- actually, with saving it's properties, one by one - going through every children, and saving it's positin and rotation. but there seem to be a little bug over there that makes such copies slightly different, if they are made like that. (

so how to avoid this?/go around it?

saved = transform;

will create a reference to the original transform, doing exactly what you described.

I think you'd want to create a new transform, then pull position, rotation, scale out, as you said, one by one, then use that (non-reference) copy to reset those props on the new object.