I am trying to use renderer.enabled = false;
to make an object invisible after it gets “hit” and before it gets destroyed as it has other jobs to do. The object itself doesn’t have a renderer though, two of it’s children do. There are many instances of the object in the game, all with the same script, so I can’t easily make the child objects invisible by using their names in the code or a public variable that I assign in the editor.
Is there a way to add to the code above to make all of the child objects’ renderers invisible?
Thanks.
You should be able to use GetComponentsInChildren to do this: http://unity3d.com/Documentation/ScriptReference/GameObject.GetComponentsInChildren.html
Thanks Matthew. Worked great!