Reference to prefab clones in my script

Hey everyone today I wrote a script that basically moves object A to object B. My problem now is I want it to move object A to one of my 3 clones (object B) of a prefeb that will spawn in when the game started. If you know how I can call those clones in my script as a target please let me know. Thanks

You may pick a reference to the instantiated Object like this GameObject target = Instantiate(ObjectB); Now that you have a reference to it you can set it as the target of Object A.

I tryed to uncheck the preload option but unfortunately nothing has changed

1 Answer

1

You can tag your prefab so every clone you instantiate has that tag and when you need to get a reference to the clones, use GameObject.FindGameObjectsWithTag().

Ok thanks for answering I will definitely try it now.