Touch screen drag and drop issue

Started by
35 comments, last by davejones 5 years, 10 months ago

I am having an issue with touch inputs on an iPad. I have a UI widget item on screen that I am trying to drag. When I test the game on a PC the widget item works correctly. When I try to drag the widget item on a touch screen (iPad) the position of the item is nowhere near my finger. So as I am dragging the item it doesn't follow my finger, however when I drag the item using a mouse on a PC the widget moves in the correct position. In project settings I have enabled the use mouse for touch option but the issue still persists. This has been set up in unreal engine 4 and I am trying to get the correct functionality for a tablet device. Any help would be much appreciated on how I would get the UI widget to follow my finger when I drag it. 

touchinputissue.PNG

touchinputissue1.1.PNG

touchinputissue1.2.PNG

Advertisement

Hi, you also need to use the "Get Input Touch State" node.

You will see in the Unreal examples provided with the engine, that both mouse and touch has it's own code. I think it is the top down example.

So you will either clone your setup and have one for touch or you will have some kind of toggle, changing between touch or mouse depending on device.

28 minutes ago, Scouting Ninja said:

Hi, you also need to use the "Get Input Touch State" node.

You will see in the Unreal examples provided with the engine, that both mouse and touch has it's own code. I think it is the top down example.

So you will either clone your setup and have one for touch or you will have some kind of toggle, changing between touch or mouse depending on device.

Hi thanks for reply. I can't seem to find the top down example you are talking about as there are many. Would you have a link to this? 

1 hour ago, Scouting Ninja said:

Hi, you also need to use the "Get Input Touch State" node.

You will see in the Unreal examples provided with the engine, that both mouse and touch has it's own code. I think it is the top down example.

So you will either clone your setup and have one for touch or you will have some kind of toggle, changing between touch or mouse depending on device.

The attached image shows what I have set up. I have used the "Get Input Touch State" node and converted the float to a vector than vector to vector2D. 

get touch input state.PNG

50 minutes ago, davejones said:

The attached image shows what I have set up. I have used the "Get Input Touch State" node and converted the float to a vector than vector to vector2D. 

Sorry, I have been awake for more than 24 hours, this makes no sense to me.

https://chrysalisinteractive.wordpress.com/2016/12/02/touch-and-drag-camera-tutorial-both-blueprint-and-c/

Try the tutorial in that link.

3 minutes ago, Scouting Ninja said:

Sorry, I have been awake for more than 24 hours, this makes no sense to me.

https://chrysalisinteractive.wordpress.com/2016/12/02/touch-and-drag-camera-tutorial-both-blueprint-and-c/

Try the tutorial in that link.

From the image I attached it can be seen that from the location X of the  "Get Input Touch State" node I have converted a float to a vector than a vector to a vector 2D. 

4 hours ago, davejones said:

I have converted a float to a vector than a vector to a vector 2D. 

Just remember to get all axis, you can't just use one float.

I see in the image you are only using X, you need both X and Y. In Unreal use a "Make Vector 2D" node, then plug both X and Y into the right slots.

11 hours ago, Scouting Ninja said:

Just remember to get all axis, you can't just use one float.

I see in the image you are only using X, you need both X and Y. In Unreal use a "Make Vector 2D" node, then plug both X and Y into the right slots.

I have tried this but still not solved the issue. 

OK. I have the oficial Unreal example here:

UnrealTouchExplain.thumb.jpg.3759ac5eac8d67dde8dd55e9b5bb918c.jpg

1.) First you will see a "Event Tick" followed by "Sequence" This is what they use to check if it is a mouse or finger input. Basically it will alternate between mouse and finger very fast.

If you game is only touch then just plug the event tick into the "Gate".

 

2.) "Input Touch" is used to read the finger here. Then two branches is used to check if it is the first touch on the screen and if it is pressed down or released. Branches are "IF" statements.

3.) The "Gate" here allows the "current" to flow or stops it. When the player touches the screen the gate is opened, releasing the screen closes it.

4.) "Get Hit Result Under Finger By Channel" Just finds the hit point. [Trace Complex] is enabled here to get an accurate point.

5.) Last the "Move to Hit Location" uses the {Hit Result} from the  "Get Hit Result Under Finger By Channel" node to move the object to the touch point.

 

This should be enough to get you started.

1 hour ago, Scouting Ninja said:

OK. I have the oficial Unreal example here:

UnrealTouchExplain.thumb.jpg.3759ac5eac8d67dde8dd55e9b5bb918c.jpg

1.) First you will see a "Event Tick" followed by "Sequence" This is what they use to check if it is a mouse or finger input. Basically it will alternate between mouse and finger very fast.

If you game is only touch then just plug the event tick into the "Gate".

 

2.) "Input Touch" is used to read the finger here. Then two branches is used to check if it is the first touch on the screen and if it is pressed down or released. Branches are "IF" statements.

3.) The "Gate" here allows the "current" to flow or stops it. When the player touches the screen the gate is opened, releasing the screen closes it.

4.) "Get Hit Result Under Finger By Channel" Just finds the hit point. [Trace Complex] is enabled here to get an accurate point.

5.) Last the "Move to Hit Location" uses the {Hit Result} from the  "Get Hit Result Under Finger By Channel" node to move the object to the touch point.

 

This should be enough to get you started.

I have touch inputs set up already. The issue is the positioning of the widget when it is being dragged. I want to drag an item from one part of the item and have another part of the widget recognise a drop. At the moment I have a UI widget which is being dragged. It is a sword. I can drag the sword from the top using a mouse. I than want to have the bottom of the sword recognise a drop when I release my hand from the screen or mouse. 

This topic is closed to new replies.

Advertisement