How to delete 2 of the same instance when they collide with eachother

I’m trying to make it so that if 1 instance is dragged over to another of the same instance either both are deleted, or one is deleted and the other becomes a new sprite.
Basically I can’t figure out how to have an action happen to both sprites.

I want it to look like 2 of the same thing combines into a new thing

The sprites spawn in randomly and walk around randomly, they can be dragged.

Any suggestions would be appreciated

Hi, the question you ask in your title is relatively easy to answer. It is as simple as:

collide_delete

Things become more complicated if you want to do something like:

because then you need to determine which of both sprites should be deleted. You could use the ‘ObjectPickingTools’-extension for that and delete, for example, the object with the lowest z-order:

This is just to give you some inspiration. How and based on which condition to delete and create the objects depends on your other events etc.

Thank you so much for replying!

The object picking tool extension definitely seems useful, although I’m unsure how to implement it because of requiring the “object was just dropped” condition.

Because these objects are free roaming, they could run into eachother and active the merge command, my work around for that is to only merge them if they are colliding and was just dropped on-top of another.
So you drag one onto the other and have them appear to merge.

So I’m having difficulty having this command effect both objects since one of them was not just dropped. I can’t think of a way to affect the non-dragged object

I see. This seems to work:

but there is probably a better way to do that.

That works!

Better way or not, that is perfect for me, thank you so much :slight_smile:

I’ve come to the realization that this code makes it so that if I drop ANY object anywhere 2 can merge, I have no idea how to specify that I want only the specific object I’ve dropped to merge.

If I attached something to your cursor and it lingered where it was dropped for a couple seconds it could help check if it’s merging the correct objects, would that work? or is that way over complicating things.

Like if say “object3” would teleport to where you were touching, and wherever you stop touching it would stay there for a few seconds as a way to tell where the cursor last was so only the objects in the area of object 3 would be effected, would that make sense?

Yes, it depends on the other objects and how you manage them in your events. My example is just for two instances of the same object.

There are always several ways how to achieve something and I would suggest to use the method that you can easily work with. Using markers, spawners and hidden objects that help you to get your events working is quite common. If you run into problems, you can still use another method later.

Yes it does and if it works then go for it.