How to drag an object with touch input?


I’m trying to have it so I can drag an object using my finger on a touch device. I’ve followed this tutorial (Content Examples Sample Project for Unreal Engine | Unreal Engine 5.1 Documentation) and then also tried the last comment from this thread (How to move a mesh based on touch location? - Programming & Scripting - Epic Developer Community Forums).

But both cause the same issue, instead of the object dragging it moves by one whenever I click on it and if I attempt to drag it then it moves to 0,0,0.

Below is my blueprint, it’s pretty much an exact copy of the one in the Unreal doc tutorial. Any help would be really appreciated.


Regarding your current implementation, I’m wondering if the “Get Hit Result Under Finger by Channel” is actually returning anything. Have you run the hit result through an “IsValid?” node to make sure you’re actually hitting something?

Regarding the task in general, if you have access to a TouchInterface, you could try using the “Create Drag Drop Operation” node. That may be a lot simpler if it works.

Thanks for your reply, I’m still learning so not sure how I would run it through an IsValid?. The object is moving on input though it’s just not dragging freely as you’d expect.

The issue is somewhere along the touch chain since when using a mouse it works perfectly.

Had a google around at the drag drop operation and I don’t think it’ll be appropriate for what I’m wanting to acheive.

Hmm, well if it’s moving then it’s probably valid. For future reference, to get the IsValid? node just pull off of the object pin you want to check and start typing in “IsVal…” and it should be one of the choices.

I’ve never tried touch-dragging myself, so I have no further suggestions. Good luck!