[Solved] FindGameObjectsWithTag, only get childs

Hi,

I would like to get the material of random GameObject’s childs in order to change its Main Color.

I think that tags are the solution to my problem but each time I use myParentObject.FindGameObjectsWithTag it ever return the complete list of all my taggued objects even if there are out of my ParentObject range.

How can I only get the childs taggued objects (if possible without comparing every ParentObject).

Have a Nice Day.

PS: I apologize for my poor english and hope you will understand my request.

Hello, Given a certain parent, you can go trough all the children of it like this:

var parent : Transform;
for(var child : Transform in parent){
    Debug.Log(child.gameObject.renderer.material.color = Color.green;
}

this changes all the colors of your children from your main material to Green.

hope it helps :wink:

Thx a lot, I don’t want to change all of the Children’s main color, but I can add a condition somewhere which test the child’s tag to fix my problem.