• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by BigGiantHead · Jan 12, 2016 at 08:35 PM · instantiationclonesaccessing

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!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by vintar · Jan 12, 2016 at 09:08 PM

You would simply say :

 movingBall = hit.collider.gameObject;
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image BigGiantHead · Jan 13, 2016 at 05:12 PM 0
Share

Oh, it was so simple! Thank you, it worked!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

37 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

my instantiation /prefab of dan wont play death animations like orignal dan 0 Answers

Reference to InputField containing the script 0 Answers

My script keeps instantiating a clone of my hero, why? 0 Answers

How to create FPSController and instantiate FPS prefab at runtime with code? 0 Answers

I have searched like the whole Internet for this lol (get Value of specific Prefab(clone)) 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges