Dragging from button to world

I’m trying to drag from a button to the world to spawn an actor.

I already have working logic for touching (everything uses a touches because the target device is mobile) on the actors and dragging them toil move them in the world. This works by setting the actor’s location to the X and Y location of a broken hit (get hit result under finger by channel)

My plan was to use the UI button’s on pressed event to spawn the new actor and set the dragging bool to be true, and then my other logic would take over and the new actor would follow under the finger until released.

The problem is that after pressing and dragging from the button, I don’t get any “hits” under the finger so the newly spawned object never moves. However, if I keep my finger down and drag the cursor out of the play in editor window onto the editor’s UI, then BACK into the play in editor window, all without lifting the mouse button (mouse simulating touch) then the newly spawned object will snap to the cursor and move in the desired way.

So I’m thinking it is some kind of focusing issue since everything starts with touching on a button instead of the world… Is there any way I can start getting world space location under the cursor in the middle of a touch event that originated over a HUD widget? Or is there a better way to implement this functionality?

Just following up for anyone else that is running into the same sort of problem:

Turns out the primary remedy to my problem was to set the button’s click and touch methods to precise click and precise tap. That sort of worked with my previous implementation, but it would cause the editor to crash constantly when testing it, I’m not really sure why.

I ended up implementing drag and drop functionality on the buttons, and on the drop function in the HUD, I then call the create function in my player controller which then does a quick hit scan under the finger or cursor and then places the actor at that location.

The only thing that doesn’t work this way is having the actor stuck to the cursor while dragging, I need to use a UI widget for the drag visual.