How to access specific Gameobject clone from many ones?
Hello community!
I'm truly a noob here, so excuse me for my silly question.
I instantiate many objects from one prefab. I try to access the specific one after identifying the correct one by raycasting. I try access the correct one from GameManager -script which has references to the prefabs and which also does the instantiation of the objects.
I try to access clone by calling GameObject.Find after the raycast returns the collider of the object in question. This is done from the GameManager script. The problem here is that it always returns the one that is instantiated first.
movingBall = GameObject.Find (hit.collider.gameObject.name);
Since all the clones are named similarly (adding the (Clone) to the end), I have no idea how to access specific clone.
Please help! Thank you!
Answer by vintar · Jan 12, 2016 at 09:08 PM
You would simply say :
movingBall = hit.collider.gameObject;
Your answer
Follow this Question
Related Questions
my instantiation /prefab of dan wont play death animations like orignal dan 0 Answers
How to create a constellation on mouse click? 1 Answer
Only spawning power ups that the player wants in that game 1 Answer
Firing projectile from Transform. What am I doing wrong? 1 Answer
Add Clones of GameObject to List(array) 0 Answers