[Solved] Fixing a bug in my game

I’ve had a bug with my game for a while now, where two blocks get selected at once and the mouse joint stays permanent. I have no idea why this happens, any ideas on how I could fix this?

Should the 2 blocks be selected, or just one?

Can you expand the add mouse joint, to show the parameters? You should be setting JointID in there.

1 Like

Only one object should ever be selected and have a mouse joint. I save the mouse joint’s id to the variable JointID and it should be getting deleted when you release the mouse, but for some reason sometimes two objects end up both selected and one permanently keeps its joint.

Are there more than 2 blocks on the screen? Are the 2 blocks that get selected overlapping, or separated on the screen?

And can you expand the add mouse joint, to show the parameters?

Here’s the parameters. there are more than two blocks on the screen and they are not overlapping.

Does the joint appear to be added to both block simultaneously, or only as the cursor moves over each block?

Here’s how I’ve had it working it in one of my games :

Add a mouse joint on the Draggables group has parameters of :

1 Like

Dang, everything seems to be pretty much the same. It appears simultaneously. Here’s a link to the current version: BuildUp by ZipZ
It seems to happen most with long objects. Try selecting the red block on level 3 and often the long yellow one is also selected. I have no clue how to fix this; it might be a bug with how GDevelop detects collisions on resized long and skinny objects; it does seem it has a larger hitbox than it should for clicking on.

Are the objects rotated?

You can see the object hit boxes by turning on debuging (it’s a selectable action).

Oh yeah you’re totally right! It is because of their collision boxes changing when rotating and then overlapping! Is there anything I can do about this?

I think MouseOver just checks the larger box which is the outer points of the image, and doesn’t use the collision box which does get rotated.

The simplest fix is to check if the mouse position is colliding with the object :


1 Like

Thanks so much, that works! Sadly roughly 30sec too late to update my game in the game jam :sweat_smile: