Hi, so I got it working:
The one thing I noticed is that Unreal's UI isn't made to test more than one collision. Like most UI it is designed to be fast as not to cause lag to the game.
So here is how I did it, Setup:
I created my sword image and from that I made 2 parts. I also added a white image to show when it is dragged. The white sword is how the "DragWidget" (Yellow box) looks.
The items we need is: Drag and drop manager, A Drag Widget to use for the dragging, the blade, the handle and lastly a item to drop it on top of.
The very first thing that is needed is rules for the drag and drop this we make the drag manager for.
We make a new "Drag Operation" Blueprint as shown in the image. It is given 5 variables that is exposed on spawn. 2 to hold the widgets, 2 more for the offset of each widget and last a Bool to see if the item inside is the sword blade.
After the setup we start with the blade:
It's just a widget with the top of the blade as a image. A important thing to do is to give it a variable to hold the handle, this variable must show in the editor (Eye icon).
The onMouseDown is simple as always.
The OnDrag is where most of the work is done. We start by dumping both the Blade and Handle into the DragWidget so we can drag only it around. The drag widget has two exposed variables for holding each item.
Next we make both items invisible.
Last we use our custom dragmanager to store our properties in. We also check the positions of the widgets and store them as offsets. Then we tell the manager that this is the "IsBlade".
Setting up the handle is the same except things are swapped around:
The OnMouseDown is exactly the same.
The OnDrag has things changed around:
It is the handle that is the "Self" now. Lastly the "IsBlade" should not be checked in the manager; this isn't the blade.
With everything ready to be dragged we can setup the HUD now:
The HUD setup is very easy, we just drag the top and bottom of the sword near each other. We can also place the target zone in.
A important part here is to tell the Blade about the handle, this is that "eye" variable we made at the start. The same must be done for the handle.
The HUD drop code:
This is the same as before but we now ask the manager for both items and offsets. This first removes the item from the dragged widget, then adds it to the HUD and the drop point, After it is dropped it is set to visible again.
Then finally we let the "Target" do something based on what part is dropped on top of it:
The code is very simple. We ask the manager if the item just dropped is the sword blade, if it is then we turn target red, if the dropped item isn't the blade, we turn the target yellow.
Can I ask how you plan on using this, for what? Because I have a feeling there is a much easier way to do what you want.