Changing child object light color

Hi!

I have an object with 5 child (4 Point light and a collider) and i want to change the color of the ligths when the collision happens. I need an invisible collider because the object looks like a donut, so technically i don’t collide with it, instead of the camera goes through it.

mainObject=other.transform.parent.gameObject;
for (var child : Transform in mainObject.transform) {
        if(child.gameObject.name == "Point light")
            child.Light.color = Color.green;
    }

But this does not work. I tried child.gameObject.color, child.color and so on but i could not find the solution.

Hi @Thorles .

Your “for” statement is working? You can get right transforms? And entering in this string comparison?
If yes for above questions, you can try GetComponent instead of Light.

GetComponent.<Light>().color = Color.green;

Try to find what is your real problem, otherwise it’s a shoot in the dark.

1 Like

Sorry i should have been more precise, but thanks to you now it works like this:
child.GetComponent.().color = Color.green;
Thank you again!