Forgive the odd question, I’m not entirely sure how to word this (hence my fruitless searches).
I am currently creating buildings procedurally at runtime and then placing them on the terrain randomly. A few of them intersect the others, which as you can imagine, looks pretty messed up.
Which makes my question how would go about placing an object where it won’t intersect a previously placed one? Moreover, what are the ideas and logic I should be following?
This can be done by checking the surround area using Physics.CheckSphere() or Physics.OverlapSphere(). It can also be done by saving the renderer.bounds for each existing objects and use Bounds.Intersects() to determine if the a new object will intersect. Note that both of these can produce a false positive since spheres and boxes can be somewhat larger than the mesh.
Another solution is to go ahead and place the building, but don’t turn on the renderer. In the next frame, check the OnCollisionEnter() to see if the new building is intersecting an already placed building. If it finds it intersects, then it can destroy itself (or return itself to the object pool).
And as @thornkey suggests, raycasting is a possibility. How much Raycast work you’d have to do will depend on the shape of the meshes and what rotations you allow.