How to get all instances of an object in the scen

Hello.

I am trying to find and store in array the instances of an object, that have been put in the scene.

Let’s say that i have a prefab with sphere inside… I drag\drop 5 times that sphere to a different places on the scene. Is there a way to get the positions of all these 5 instances, by JavaScript, so i can use them later for certain pusposes? Like some way to get access to all of the instances, that one prefab (or object) have on the hierarhy\scene.

The JScript, that i’m trying to access them is attached to another gameObject.

Thank you :slight_smile:

I recommend you to create a list to save the reference for each object you spawn. Otherwise, to find it all I recommend you to create a tag and use GameObject.FindGameObjectsWithTag(“yourTagName”).

cool, thanks will try the the Find with TAG…

But if there are 5 objects in the scene, assigned to that TAG, is it going to return them as array? Will i be able to control each of them separately?

Thanks