if i have instantiated gameobjects under a parent object and then after instantiating i need to despawn some of these children randomly how can I achieve that .

if I have instantiated gameobjects under a parent object and then after instantiating i need to despawn some of these children randomly how can I achieve that .

class Spawner : Monobehaviour
{
Transform parent;
List children = new List();

     void DestroyKids( int amount)
            {
                      if (children.Count == 0) 
                            return;
                      if (amount > children.Count)
                            amount = children.Count;

                      for (int i =0; i < amount; ++i)
                       {
                               Transform randomChildToSacrifice = children [Random.Range (0, children.Count)];
                                children.Remove(randomChildToSacrifice);
                               Destroy (randomChildToSacrifice.gameObject);
                       }
             }
}

have you tried list.Add(GetComponentsInChildren())?
Can’t try it out here but you need the parent make know the reference. You can find it by tag, find children etc.