UI Dragging And Snapping System?

Hello DevForum!

I’m trying to create something like IProgramForFun made with his game ‘Dwiddle’. It’s an inventory system where you can drag frames around and make them clip to the nearest slot. The problem is, i have no idea how to do the dragging system. I could really use some help, thanks!!

2020-11-24 14-27-08|video
Example ^^

Hi. I know some stuff. I don’t think you need to code this. Their maybe an anchor depending on what you are using. I could be totally wrong. It also may depend if you are using images to drag or not. Like I said I could be wrong on what I am saying but I believe I have done it before.

heres a module ive previously used. It’s easily solved your problem for dragging. snapping is another thing though, but I bet it cant be too hard.

1 Like

Ive been facing the same problem! Heres my solution:

Add a boolvalue to the drag part called isDragging, with the value to false.

When you MouseButton1Down the ui, set the value to true, and make the UI draggable.

When you MouseButton1Up the ui, set the value to false, and make it not draggable.

When your mouse mouseEnter’s the gui you want to snap to, check if the isDragging property set to true, if it is, set the uiyouwanttodrag’s position to the UI your mouse entered.