this like a drag and drop widget,but there is a frame limits the point’s movement. And the point is being pulled by center anchor and spring arm. I try the document Creating Drag and Drop UI, it create a virtual widget following my mouse cursor, not the original widget.
Somehow I feel that Drag & Drop is not the right way of doing it. I would encapsulate this behaviour inside a widget so you can have more of those areas if necessary (currently you’re moving it within a viewport):
here I’m using a canvas to shift an image within it:
Pretty sure there’s half a dozen way to handle this though. The gut feeling tells me there’s a huge gotcha with dragging that would make it finicky to handle. Might be wrong.
The widget is created in the Level Blueprint, the mouse release is handled there as well - this is needed with this method in case the drag ends up outside the widget and the player conttroller detects release instead of the widget.
If I find the time, I can have a look at drag & drop method for this, too. Maybe it will not be so bad. But the whole idea is to clamp the vector to the local size of the widget that you’re using. Drawing line is done from the centre of the widget to that bounded vector. This part will be similar for whichever method we opt for.
There is a little problem. when use in mobile phone, i replace “Get Mouse Position on Viewport” with “Get Input Touc State”, replace “Left Mouse Button” with “Input Touch”, the results were terrible