Dragging 3D object 'out of' a UI button but position not updating when holding

Hi all!

I’m trying to create an interaction where you’d press a UI button without releasing to drag out an object to place into the 3D scene.

The UI button will call an event to spawn an object when the button is pressed.

Once the button is pressed, the GetHitResult node is then used to get the current raycasted position in the scene from where the mouse is at.

This is the graph in the UI widget blueprint:

And this is the event being called from the UI widget being pressed:

The current issue is, the position of GetHitResult doesn’t update if I press the UI button and do not release aka ‘holding on to the button’ while moving my mouse in the scene. Only if I click the button then release and then move around in the scene, will the GetHitResult start to update position values.

Would anyone know why this has to be the way? Im guessing it’s the UI button overwriting the gethitresult triggers? Would anyone know how to get the desired result of holding onto a button while being able to update traced positions?

Im a newbie to unreal and have been stuck on this for a long time… any suggestion welcome!!

I believe this is what you’re after:

Kind of, close. When the widgets are handling input, the player controller has no idea what’s going on. You will always find these 2 compete and consume input.

THANK YOU! YOU BEAUTIFUL CREATURE <3 !!

Took me a while to follow through and figure out the steps you presented in the linked post but it was very well explained and I finally got it working!

I was wondering why a seemingly straightforward action would need so many different links of events… I’m super new to unreal so this is a great learning experience…

So,. the whole reason we needed a separate Drag Operation Blueprint is to get the ‘dragging position’ from them? Because we can’t get the current position from mouse because of the UI / Player Controller ‘fighting’ issue?

And the whole reason the DragCoords has to be in PlayerController instead of just be in the Drag Blueprint or in the Dragged item blueprint, is because there’s no other way to convert screen space to world? (for example I can’t find the AbsoluteToViewport node in other blueprints)

Just want to learn more about unreal blueprints, and wonder if there’s a way to approach this in a simpler fashion :confused: really dunno much about this engine, and thank you AGAIN for the pointer, I’d had been stuck for a while if it wasn’t for the post :pray:

1 Like

so many different links of events… […]if there’s a way to approach this in a simpler fashion

Let me clarify; what I originally suggested is suitable for a situation where you want both - dragging a widget and dragging an actor around simultaneously.

Spawning and dragging after an interface click is easier as we don’t care about widget position:

Image from Gyazo

The above should be in the Player Controller. Here the button was set to Mouse Down so it releases focus even though its Up never happens and the controller can take over:

image


So,. the whole reason we needed a separate Drag Operation Blueprint is to get the ‘dragging position’ from them? Because we can’t get the current position from mouse because of the UI / Player Controller ‘fighting’ issue?

It’s somewhat convoluted how input bubbles between widgets but yeah, pretty much. Most of the time, we’re in this mode:

Interact with a widget and choose what happens with the input next (here, a click):

Pass Handled to consume input & terminate. Pass Unhandled so another widget may process it (if they’re underneath, for example). If no other widget Handles it, the Player Controller will get it. So yes, you can click through widgets and get both the PC and the UI to manage the very same input.

However, the problem with dragging is that it does not let you return such reply.

image

Technically, you could fill the entire screen with another transparent widget, override onMouseMove and reply with Unhandled but that’s even a bigger hack than the original solution.

And it would make working with other UI elements awkward.

1 Like