ignore any child colliders too?

How do physics ignore collisions to include all of any of an objects child colliders? I tried to plug in GetComponentsInChildren but I get errors with each attempt. With this code, it will atleast ignore colliders on first depth search

in Update(){

if(blah){
ignoreCollision(“Player”);
ignoreCollision(“Pet1”);

}
}

function ignoreCollision(tag: String) {
var objects = GameObject.FindGameObjectsWithTag(tag);

for (var o in objects) 
if (o.GetComponent(Collider) && o!= gameObject) {
Physics.IgnoreCollision(o.collider, collider);    

		}
	}

1 Answer

1

Iterate on each object’s transform to get their children. Recursively. Or make use of Layers.

What did you have in mind for iteration? The only things I could think of was to add another for(o2 in o) which only gave me error messages saying that it was not inumerable. I heard of using layers in another comment, but after checking the docs it said that the feature was for unity3x. How do you use layers for regular colliders in the free version?