How to adjust the clickable area of a sprite

I’m making a drag and drop dress up game and I’ve got everything basically working correctly but I’d like to make it so that the clickable/draggable area of each object is more specific.

As it is now, since there are a lot of overlapping objects, when you try to click a shirt or something you often end up picking up something else nearby instead of the one that you want (often over and over so you have to move a bunch of stuff out of the way just to grab something that was clearly visible from the beginning)

Is there any way to customize the shape of the clickable area (similar to how you can customize the hitbox)? The image files already have all the extra trimmed off, the problem is that the clickable area is a rectangle while the object is not.


Thanks for your reply!

Unfortunately that seems to have no effect in this case as the draggable behaviour doesn’t consider the custom hitbox, it just uses the default rectangular area. In the mean time I did find this thread Draggable behavior ignore the shape and size of custom hitbox and rotation of object · Issue #1298 · 4ian/GDevelop · GitHub so it would seem that it’s a known issue.

1 Like

You can work around with it, for example create a new object named “Hitbox” and assign this with a draggable behavior. After that add this action, Position X n Y of “YourObject” to Hitbox.X() and Hitbox.Y(). Dont add condition.

Now just adjust your hitbox to what fills your desire. Hope this helps

This example…

Drag and drop with placeholders

… shows a custom-made drag-and-drop system that uses the hitbox area of the sprite.

Thanks for your reply!
Pardon my ignorance, just trying to understand before I try to implement this- so if I did it this way I would have two sprites for every item in my game, where one is unseen and draggable with a custom shaped hitbox, while the other one is my image and is not “draggable” per se but is attached to the other object which is? Is that correct?

Thanks for the link! I don’t think this is quite what I’m looking to do (as a kid when I played these games I always preferred the ones where you fully had to position the clothing yourself, I think because it feels more hands-on) but it might come in handy in the future.

What you need is in that project.

That’s why I explicitly told you:

You don’t have to implement the placeholder part of that project, just use the drag-and-drop work around that allows you to use custom hitboxes.

Yes that is indeed correct.