count how many gameobjects (with childiren) are in trigger?

Hey!
I somehow cant figure out how i can count the amount of gameobjects (characters) insider a trigger. since its a character, it has many child objects. how can i count them? thanks!

If its children of the same parent you want to count you can use this

//Attach in script of parent
Debug.Log(transform.childCount);

But from the lowest child position / deepest child then you would need to do something like this

public GameObject obj1;
private int i = 1;

start(){
obj1 = GameObject.Find("obj1");
}
update(){
while (obj1!= null) {
    //add stuff here
    i++;
    obj1 = GameObject.Find("Object" + i);
}
}

//not tested but you get the idea, just 

But for what you want, then just do a ontriggerenter and in that cal the transform.childcount which will return the total amount of “bodies” in the trigger (parents + children)

void Start()
{
// -1 because the GetComponentsInChildren also returns the parent’s Transform component.
int numberOfChildren = GetComponentsInChildren().Length - 1;
}

If you don’t want all children to be counted just change Transform for example to Renderer (or whatever all the children you wanna count have as a component).