Question by 
               brainwreck · Jul 16, 2020 at 02:33 PM · 
                gameobjectinstantiatelistcolliderscollision detection  
              
 
              Check if a large number of gameobjects are colliding
I have a List<GameObject> trees that contains a number of trees I've randomly Instantiated into the game. Essentially, I have a function that instantiates n trees at random locations using a list of prefabs, and once it has instantiated one, it adds it to the list.
However, sometimes you get collisions when two trees are spawned atop one another, and the two trees clip into each other. Is there a way I can check if any two GameObjects in the list of trees are colliding, so I can regenerate them? I can't use IsTouching because it would require n^2 comparisons, which goes into the range of 20000 once I start generating hundreds of trees. 
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Instantiating GameObject and Adding to list 3 Answers
Changing GameObject values from a list 0 Answers
