Drag and drop components

I’ve been building an interactive quiz for my website and needed a reusable drag-and-drop system in Rive. The result is a set of components that handle the full interaction loop: dragging, dropping, collision detection, win/lose logic, and reset (if the result is wrong). I have just uploaded a fully working sample of the Rive file, using colored boxes instead of the labels I will be using on my website.

It has turned out to be much more challenging than I anticipated. I am wondering if I have overcomplicated it and there is a better way to achieve similar results. The file uses a shared DiagramState view model with nested LabelState and TargetState instances for each draggable element and drop target. A ghost label follows the pointer during drag. All game logic lives in two Luau scripts: TargetAction and DropAction attached to listeners, which handle collision detection, state updates, win detection, reset on failure, and blocking the animation after a successful attempt.

My current implementation works pretty well, even if it looks too complex to me. The biggest limitation is that adding a different number of labels/targets requires too many manual changes. Maybe using lists could help?

If anyone is interested in this implementation, I am happy to answer questions about my design decisions. In any case, this has been an excellent learning exercise for me since I am really new to Rive.