- Home /
Question by
MyNameisMyka · Jun 26, 2020 at 11:48 PM ·
c#scripting problemgameobjectmaterialtransparency
Change the alpha of a gameobject with multiple childs
Okay so, i have a house GO with multiple childs and i would like to make the childs transparent when the player enters on the house, is there any way to change the alpha of the childs or the gameobject since they do not use the same mats, just need to know how to! btw i'm using OnTriggerEnter to get this working
Comment
Answer by tuinal · Jun 27, 2020 at 12:10 AM
List<Renderer>() allChildRenderers;
allChildRenderers.AddRange(GetComponentsInChildren<Renderer>();
foreach (Renderer r in allChildRenderers){
Color c = r.material.color;
c.a = 0.5f;
r.material.color = c;
}
So, should i put this inside the OnTriggerEnter? Sorry, I'm new to this