Random Object Spawn without Overlap

In recent projects, I have had the need of generating a bunch of objects in random locations within a radius/box/whatever. That part, I can do just fine. The problem is, I don’t know how to spawn them without them overlapping each other. I tried a BoxTrace that checked to see if it overlapped one of the objects, and to try again to find a new point if it did. However, this (even when using a recursive loop) didn’t work and caused an error for an infinite loop. I’ve been struggling with this for so long, but just can’t seem to solve the problem. Does anyone have an idea of how to do this properly? I would appreciate the help and a swift response, thanks.

Random and box trace sounds fine. But you will get loop problems if you specify too many objects for the space given. What I mean is, the randomness gives you a good chance of missing the other objects anyway, but once you reach a certain threshold, you will always be re-searching…

Thanks. One of the things I used it for doesn’t really even need to check for collisions, so it can remain the same. When it comes to generating say, a forest, then I need more objects to spawn but can’t because of the limit on them. Also, the recursive function doesn’t move it to the new point that’s specified by the loop. The aforementioned tree generation loop consistently spawns trees that overlap one another, but I do see the trace shown as hitting something and creating an empty box that should contain a new tree. That has become the newest addition of problems to my project, recursion has always given me headaches and I can’t seem to get it to return the correct value and move the tree to a new coordinate.