[Solved] How to delete old objects when new one is placed on top?

Situation: I have a few objects already placed on a grid.
When the new object (shown below the grid) is placed on top of an existing object, the new object should delete the old one and replace it.

Whats the best way to do this?
GDev_placedobj

If you’re using the drag behavior. Add a layer. Move the object being dragged to that layer. When the object is dropped, delete the object on the base layer. Move the dropped object back to the base. This has the benefit of making sure the object being dragged is on top of everything.

This would pick the nearest object and move the dragged object to that position using X, Y variables.

Thanks @Keith_1357 for the brilliant solution as always!

1 Like