Differentiate two close objects with the mouse pointer?

Hello !
I have a lot of objects in my game. They are not rectangular at all, and can some times be close from one an another. In my game, stuff happens when you pass your mouse on the object, but now, because the object is rectangular and not his real form, it also happens when you are not on the object, but only close from it (and can happen to 2 objects at the same time !)
I tried already to change that through the hitboxes, but it seems hitboxes are only for collision and not pointers.
Does any one know how I could do correct that ?
Thank you

In theory you could hide the mousepointer, then create a sprite that always is moved to Mouse.X and Mouse.Y positions. Now you can use hitboxes to check for collisions.

Otherwise try better algorithms to figure out which object would react. As this may always be a close situation Iā€™d rather go for user feedback. Highlight somehoe the object that would receive the action somehow. You could render it bigger, or you could draw a circle around. Whatever you like but understandable for the user.

1 Like