• 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 /
avatar image
Question by Jithak · Mar 28, 2013 at 05:25 PM · instantiatechildrendererclonegetcomponentinchildren

Access the renderer of a clones child object

Ok, I'm becoming desperate here after 2 h of googeling and probably making a really dumb mistake.

I'm instantiating arrows where the gameobject is the arrow with the model as a child. When something is hit after a time the arrow destroys itself (which is working fine) but I can't get any fading in because there is no renderer on my childobject. But there is.

I've tried stuff like:

 MeshRenderer[] render = gameObject.GetComponentsInChildren<MeshRenderer>();

 Transform childTransform = transform.FindChild("arrow");

 MeshRenderer childRenderer = GetComponentInChildren<MeshRenderer>();

 Transform childTransform = transform.FindChild("arrow");

and various other things. Also everything with gameObject. or transform. before. But the script is attached to the arrow gameobject so this shouldn't be necessary. Oh and of course I can't access it through the gameobject directly.

/edit parent prefab http://i.imgur.com/Bsw6Yrg.png child http://i.imgur.com/K2eYfYx.png

in the parent script I stop the arrow once it hits something so it sticks out and turn it to kinematic. later it gets destroyed. the only thing I want to add that doesn't work is a fading effect before it get's destroyed but I always get an error that there isn't a renderer.

Comment

People who like this

0 Show 10
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 whydoidoit · Mar 28, 2013 at 05:27 PM 0
Share

Can you post a screenshot of your hierarchy view for these objects with the inspector showing first the parent object and another showing the child object that you are looking for the renderer on. You can do this by editing your question.

avatar image justinl · Mar 28, 2013 at 06:14 PM 0
Share

yes please more information. I'm having a bit of difficulty understanding what you're asking with just what you wrote.

avatar image Jithak · Mar 28, 2013 at 07:35 PM 0
Share

I edited it in. Hope that makes it a bit clearer what my problem is.

avatar image justinl · Mar 28, 2013 at 07:54 PM 0
Share

What's the error specifically? What line of your code does the error happen on?

avatar image justinl · Mar 28, 2013 at 08:15 PM 1
Share

instead of showing us a picture of your prefab, how about we see the actual object being instantiated in the game. Also share more of your script.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by whydoidoit · Mar 28, 2013 at 09:05 PM

You have missed the child off the word renderer in this line:

  childRenderer.material.color = Color.Lerp(renderer.material.color, Color.clear, 5f);

Should be:

   childRenderer.material.color = Color.Lerp(childRenderer.material.color, Color.clear, 5f);
Comment

People who like this

0 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 whydoidoit · Mar 28, 2013 at 09:06 PM 0
Share

Not that this line makes much sense - it will immediately turn the color to Color.clear.

Lerp needs running over time with an incrementing value between 0 and 1 in the final parameter .

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

12 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

Related Questions

Prefab clones behaviour 0 Answers

Destroy One Child, Not All 2 Answers

Disable multiple child components 1 Answer

instantiated Gameobject trying to access child of child which is a clone itself. 2 Answers

[SOLVED] How to make to clone an object and make it parent of the transform? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges