How to make sure an object doesn't spawn on top of each other

I have tried to use the “move x away from x” but I have a script that deletes the objects when they collide with each other and the objects get deleted. How do I solve this?

This happens quite often when going into preview and I don’t know why.

Duplicate your original object and append the work “_check” to the duplicated object.

Put the spawn position into 2 variable. Create the “…_check” object at the spawn point.

If it collides with the other object, change spawn position and repeat the process until you don’t have a collision between the object and the check object.

Once there is no collision between the check object and object, delete the check object and place the new object at the spawn position.

The deletion script is to test if the moving away works? Because why would you want to delete an object when you are trying to move away from it. I think you need to play with the “ignore objects that are touching each other on their edges” setting. I would recommend this setting on the deletion of the object, this means the moving away gets priority.

EDIT: In addition to this, you can also create a variable of the X position of the spawned object. And every time you spawn a new object look at the variable and add the width + /width to the new object’s spawn location so it spawns next to the previous spawned object. And also change the variable to the new object’s spawn location.