Position how to avoid objects on the same position?


hi,

I have multiple objects on a map.

Actually, i do simply :

var random = (min, max) => {
    let num = Phaser.Math.Between(min, max)
    return num
}
    for (var i = 0; i < 5; i++) {
        o.circle[i] = new Circle(g, random(100, data.w_object - 100), random(100, data.h_object - 100), "circle")
    } 

How do you do to be sure that an object is not an a same position than an others ?
As you see in my pintescreen i have object at the same positions or nearly positions…How to avoid that ?

My question is not clear.
How with arcade physics be sure that a random object is not at the same position than an another ?
i test with collider and a group but i have always multiple objects who are touching.

this jsfiddle is exhaustive

i havent tried any physic within phaser. but trying to help with my understanding of unity collision.

  • try check for collision after random placement.
  • if there are any collision within new object.
    • move created object with new random number.
    • repeat these until there are no collision within the object