[SOLVED] Need Help with Instantiating...

So I am instantiating an object, and the instantiating works fine – I just want it to be easier to debug, so I want to have the clones be a child of the object triggering the instantiation. Am also wondering if it’s possible to change the clones’ names?

Any help would be greatly appreciated!

– Chris

There are 3 overload methods of Instantiate in which you can specify the parent - Unity - Scripting API: Object.Instantiate or you can set the transforms parent.

GameObject inherits name from object so it’s just a matter or setting that to what you want - Unity - Scripting API: GameObject

Oops, had a typo in my code that was causing the parent to not work as expected :sweat_smile:

As far as the naming, I’m talking about changing the name of every cloned object, because by default they are all named like “original object name” but could I have each clone be named like “[original object name] (Clone) [clone #]”?

I’m not sure if there’s much value here beyond seeing it in the editor for debugging (and even then, I’m not sure it’s a big help, unless you’re outputting object names in the console when something happens), but…

GameObject yournewGameObject = Insantiate(blah blah blah);
yournewGameObject.name = "whatevertheheckyouwant";

To do exactly what you said you want, you’d need some running counter as you loop creating the objects, and then just use that counter to change the name to whatever you want + "[clone " + counter + “]”.

1 Like

That makes no difference – “What you name it”. If you kept track of the count, you can just set the name to whatever you want… if you really wanted to do that :slight_smile:

1 Like

That helped! Thanks! :slight_smile:

1 Like