When mouse is over 2 of the same object, only choose one

If there is 2 instances of one object overlapping, and the mouse is touching both, how could I make it only read one of those instances.

You could probably just add the “pick random instance” condition as the last condition of the event to only pick one of the remaining.


Is your problem that in the specific case of two objects overlapping, when the cursor is over the overlapping area, you want to choose one of the objects? I’m curious to know if you find an answer to this. I played around with many different implementations of how to do this and couldn’t find a workable solution. Even using the pick random object and using the ObjectPickingTools extension, I couldn’t find a way to pick a specific object, the events always applied to both.

A possible workaround to this is when you spawn the objects (I assume you do it randomly and is why they overlap sometimes), you could have a condition to check if an object is in collision with another and then separate them, or delete the object and execute the random spawn event again until an object is spawned that doesn’t overlap.

I did the pick random object thing and it worked fine. But like silver streak said, it might be important to have that condition at the end.
I think you might be able to do the “separate objects” action too, but I didnt want to do that.

So you got it to work even when the cursor was on two overlapping objects? Can you post a screenshot of the events that handle this? I’m very curious to see if I can replicate it, because I couldn’t make it work using the pick random objects event/condition for some reason.

Crap never mind I realized what I was doing wrong, I (like an idiot) used the “is pressed” condition for the mouse and it replayed the condition every frame and chose multiple “random” instances of an object group, but since it was replayed every frame, even though the mouse was pressed for a fraction of a second, all the instances were effected. Glad you got it to work.

1 Like