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.

parent prefab


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.

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);