Drag Drop Operation Drag Visual

Hello, I’ve managed to create a Drag & Drop system correctly but I wanted to know if it’s possible to have an Actor as the Default Drag Visual?

Basically instead of having a Widget as the dragged visual, I want it to be an Actor since the objects I’m currently dropping are Furnitures. Is there a way to implement it? I’m thinking I can implement it here in the On Drag Detected Function but unsure how. Any help would be appreciated, thank you!

You cannot have an actor as a visual. But nothing stops you from spawning a furniture actor at this point and trace to position it (the visual widget can be invisible).

Check this out:

This can be made much simpler if you do not need a drag visual widget at all.

Pass Unhandled during onMouseDown → Spawn an actor and send its reference to the PC (or, better, call the PC and have it spawn actor from class) and start tracing.

The widget can use screen position to trace but it can be cumbersome at times. Better have the PC handle that.

One reason to do it in widget is when you need to drop the whole thing onto another widget. But that’s not what we want here judging by the description.

2 Likes

Actually, I got this to work! :smiley: Thanks to the post you’ve made before. Thank you for that. :grinning:

2 Likes

Hello again. Sorry for updating the post. I was looking into adding additional functionality on this one like whenever the dragged actor is overlapping another actor it won’t drop. I’m a bit confused if I put this inside the custom drag and drop operation during Event Dragged? Or I put this inside the Actor Blueprint with the Event ActorBeginOverlap. Thanks in advance for the help.

I can’t recall the details of what we’re doing here. Are we dragging an already spawned actor around and only drop it when the mouse buttons goes up?

Perhaps, during the drag, asking the dragged actor to:

image

is enough, and if the Last Index = -1, we do not drop.


If you need visual feedback, you can call it every frame, or use Begin / End overlap - or even dispatch those events so we do not burden every dragged actor with the same script.


There’s probably half a dozen ways to accomplish it:

  • or with Sweep that would actually prevent the intersection in the first place:


How to approach it depends on the details / desired result and what is supposed to happen once we’re in a position preventing us from placing the actor.

Hope I got the intent right.

Thanks for the quick reply! :grinning: What we were doing before is dragging an actor from a widget and then spawning it. I followed the tutorial you made before, it was this one:

I was able to follow through it and it’s working perfectly. I will try to apply this first then get back to you. Thanks again!

Hello, I’m back. :smiley: I followed your advice and added the Get Overlapping Actors Node. I added the node in my custom Drag and Drop operation. See the following image below:

Now my only issue with this one is that whenever the branch is set to true the actor being destroyed is the one already in the scene but I want the one I’m dragging to be the one destroyed or rather than being destroyed, is there a way to cancel the drag?

You’re destroying the actors you overlap. Destroy the one you drag instead:

Also, do not do == 0. If the dragged actor overlaps more than 1 other actor, it will not work correctly. You probably meant this here:

image

1 Like

Thanks for the reply! This is what I’m looking for :smiley: There was an error “pending kill or garbage” but I managed to fix it. Thanks again!

1 Like

Hello again. I am just curious what did you attach to the Location of the SetActorLocation node?

Most likely Get Hit Under Cursor since it was to demo some other behaviour. Not sure how it matters here, though.