One way of doing this is to have whatever script is managing these instantiations to keep a list of references of these objects. I don't know if these objects are being generated all at once at startup or continually through the game but, in any case, before creating one object you check the list of current objects and see if the intended position for the new object is already occupied by someone on the list. If not, instantiate the object and add it to the list.
To check for intersection you could use transform.position simply (if the magnitude of pos1 - pos2 is smaller than some threshold return true) but that doesn't guarantee there won't be intersection if you have objects with largely different shapes and sizes. The ideal solution depends on what you're doing, really. Maybe intersection is not a problem. If it is, I'd probably use physics collision system, with some function like physics.spherecast or cube or capsule etc. Or maybe you are instantiating things on a grid, then instead of physics, or transform.position I'd use simply the grid coordinates.
I hope any of this helps.
↧