Getting Mouse Position During Drag and Drop UMG

Yes but to what is connected the FinaliseDrag? How the engine knows that I’m no longer dragging?

You call it yourself when you finalise drag - not sure how you want it to work.

  • mouse button going up can be the trigger
  • perhaps there is a slot / special place trace detects - that could be the trigger, too
  • or maybe the chair can have overlapping collision and hit another collision volume, this could terminate the drag and set the proper collision
  • you could evoke it when the drag gets Cancelled
  • you could add a reference to the spawned actor to the drag operation as payload and have onDrop set the collision, like in the example above:

The drag operation knows which actor it is dragging, so it could:

1 Like

Thanks for the explanation but I can’t get it to work, my problem being that I need the object to have a collision since after the player needs to be able to move the actor in the scene like this:

I could stay on the current functioning as on the video with the yellow armchair, but I find it more “complete” to drag the object directly and not only its texture

I tried to call it On drag cancelled but I have no return…

If you’re using a custom drag and drop operation, you can do it there:

image

image

Since we’re not dropping on a widget, and there’s no return confirming successful completion, this cancellation will trigger inside the operation blueprint.

If you’re going to use this method for a variety of classes (assuming there will be more than just chairs), you will also need to look into either inheritance and / or interface communication. Casting is not sustainable. But that’s for later.


Or use a channel for tracing, then you no longer need to worry about enabling / disabling collision. Both would work but require a slightly different approach.

Could I just ask what custom channel for tracing you would recommend to do such a thing ?

There’s nothing to recommend. You add a new one and give it a name. The chair ignores it, the floor does not. Use it as you trace.

1 Like

Finally! Thank you for the 50th time.

1 Like

There is another way of having a line tracer work as usual with the “On Dragged Cancelled” event. Thanks to “THE IMAGENEERS” on YouTube for making a video about this (link).

Here is the blueprint for spawning as example:

2 Likes

I got this hit on google and after trial and error came to that same solution.
Here’s a breakdown:
In the widget you are drag/dropping, use the Event on Drag Cancelled override.

Then, use a 0.05s or some value like this as a delay with a boolean to determine if your drag was holding onto a widget.

What happens is that the action is cancelled and the delay given allows the system to recover the position of the cursor, and then it can determine what is under it. In my use-case I used a trace since I needed something else.

If a value in the delay is of 0.01s, depending on FPS, the event may misfire, so use a value where people cannot see the difference, under 0.1s.

In practical terms, this is easier to implement with less overhead and less places to debug.
It’s not an exact method, but if your usecase is to drag and drop from a widget to world space, this works fine.