# Drag Drop Operation Drag Visual

**URL:** <https://forums.unrealengine.com/t/drag-drop-operation-drag-visual/677924>\
**Category:** Blueprint\
**Tags:** unreal-engine, question, Blueprint\
**Created:** [October 27, 2022, 3:17am UTC](https://forums.unrealengine.com/t/drag-drop-operation-drag-visual/677924 "2022-10-27T03:17:35Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vinsent](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vinsent/32/88707_2.png) [@Vinsent](https://forums.unrealengine.com/u/Vinsent)\
**Post date:** [October 27, 2022, 3:17am UTC](https://forums.unrealengine.com/t/drag-drop-operation-drag-visual/677924/1 "2022-10-27T03:17:35Z")

</div>

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?

 ![DD](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/5/7/55770e1659bb51ab1ca8f481ed67f6d7ac242f1d.png)

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!

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [October 27, 2022, 6:30am UTC](https://forums.unrealengine.com/t/drag-drop-operation-drag-visual/677924/2 "2022-10-27T06:30:18Z")

</div>

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:

> [@Getting Mouse Position During Drag and Drop UMG](https://forums.unrealengine.com/t/getting-mouse-position-during-drag-and-drop-umg/85760/15):
>
> Because it's undocumented, arcane knowledge obtainable only by those knowing a secret handshake. The below assumes you have overridden and using a Game Mode, a Player Controller and created a custom Drag & Drop Operation. in the Player Controller A Custom Event converts screen space to world space via deprojection and sets actor’s position: in the Custom Drag & Drop Operation blueprint Event Dragged spits out screen space coordinates and feeds them to an Event Dispatcher, we…

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.

---

<div class="post-metadata">

**Author:** ![Vinsent](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vinsent/32/88707_2.png) [@Vinsent](https://forums.unrealengine.com/u/Vinsent)\
**Post date:** [October 27, 2022, 8:32am UTC](https://forums.unrealengine.com/t/drag-drop-operation-drag-visual/677924/3 "2022-10-27T08:32:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Vinsent](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vinsent/32/88707_2.png) [@Vinsent](https://forums.unrealengine.com/u/Vinsent)\
**Post date:** [December 16, 2022, 9:26am UTC](https://forums.unrealengine.com/t/drag-drop-operation-drag-visual/677924/4 "2022-12-16T09:26:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [December 16, 2022, 9:49am UTC](https://forums.unrealengine.com/t/drag-drop-operation-drag-visual/677924/5 "2022-12-16T09:49:34Z")

</div>

> [@Vinsent](#):
>
> I was looking into adding additional functionality on this one like whenever the dragged actor is overlapping another actor it won’t drop.

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/5/4/454e0210c87fc01d94cb9a967dc8068804923a7f.png)

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:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/5/0/5507c7db816ffa7a67e6709b51147346425dd267.png)

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

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/e/4/6e4c64e43b6ed79833aab3001e251550ed778abd.png)

* * *

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.

---

<div class="post-metadata">

**Author:** ![Vinsent](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vinsent/32/88707_2.png) [@Vinsent](https://forums.unrealengine.com/u/Vinsent)\
**Post date:** [December 16, 2022, 10:18am UTC](https://forums.unrealengine.com/t/drag-drop-operation-drag-visual/677924/6 "2022-12-16T10:18:13Z")

</div>

Thanks for the quick reply! 😀 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:

> [@Getting Mouse Position During Drag and Drop UMG](https://forums.unrealengine.com/t/getting-mouse-position-during-drag-and-drop-umg/85760/13):
>
> 3a. Use the AbsoluteToViewport node to convert the desktop coordinates to pixel position in the screen before the deproject. Otherwise it works fine in fullscreen, but not so much in windows.

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!

---

<div class="post-metadata">

**Author:** ![Vinsent](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vinsent/32/88707_2.png) [@Vinsent](https://forums.unrealengine.com/u/Vinsent)\
**Post date:** [December 16, 2022, 10:55am UTC](https://forums.unrealengine.com/t/drag-drop-operation-drag-visual/677924/7 "2022-12-16T10:55:00Z")

</div>

Hello, I’m back. 😃 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:

 ![BP_DragAndDrop_CustomWithOverlappingActors](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/2/b/e2b92d34160c60f30a2dd22dc3ef6c1205355f21.png)

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?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [December 16, 2022, 11:34am UTC](https://forums.unrealengine.com/t/drag-drop-operation-drag-visual/677924/8 "2022-12-16T11:34:49Z")

</div>

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

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/4/6/046c865ebda95ce25cf0b618e9862af13637c8b5.jpeg)

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/2/c/e2cdae785cd255f81ff206c59b93e852bd26c465.png)

---

<div class="post-metadata">

**Author:** ![Vinsent](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vinsent/32/88707_2.png) [@Vinsent](https://forums.unrealengine.com/u/Vinsent)\
**Post date:** [December 16, 2022, 11:46am UTC](https://forums.unrealengine.com/t/drag-drop-operation-drag-visual/677924/9 "2022-12-16T11:46:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Vinsent](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vinsent/32/88707_2.png) [@Vinsent](https://forums.unrealengine.com/u/Vinsent)\
**Post date:** [December 19, 2022, 10:20am UTC](https://forums.unrealengine.com/t/drag-drop-operation-drag-visual/677924/10 "2022-12-19T10:20:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [December 19, 2022, 11:02am UTC](https://forums.unrealengine.com/t/drag-drop-operation-drag-visual/677924/11 "2022-12-19T11:02:40Z")

</div>

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