- Home /
iOS -Touch position unchanged, deltaPosition reported
I am experiencing a problem with the positioning of multi touches. In two consecutive calls to Update, the actual position on both axis remained the same for a particular touch, however a non-zero value was reported in the deltaPosition for that axis. Am I attempting to read deltaPositions for touch phases that don't support them perhaps?
My code and debug follows:
Code
void Update (){
foreach (Touch touch in Input.touches) {
if (touch.phase == TouchPhase.Stationary){
continue;
}
if (touch.phase != TouchPhase.Began){
float previousX = touch.position.x - touch.deltaPosition.x;
float previousY = touch.position.y - touch.deltaPosition.y;
Debug.Log("Touch No:" + touch.fingerId);
Debug.Log("Touch PosX:" + touch.position.x + " - Delta PosX:" + touch.deltaPosition.x + " = " + previousX + " ||| Touch PosY:" + touch.position.y + " - Delta PosY:" + touch.deltaPosition.y + " = " + previousY);
}
}
}
Below is the debug that is output from the above code.
Touch No:0
Touch PosX:1272 - Delta PosX:12 = 1260 ||| Touch PosY:227 - Delta PosY:30 = 197
Touch No:1
Touch PosX:1264 - Delta PosX:19 = 1245 ||| Touch PosY:365 - Delta PosY:-99 = 464
Touch No:0
Touch PosX:1267 - Delta PosX:-5 = 1272 ||| Touch PosY:291 - Delta PosY:64.00003 = 227
Touch No:1
Touch PosX:1264 - Delta PosX:2 = 1262 ||| Touch PosY:365 - Delta PosY:-5.000061 = 370
Read up on how capacitive touch screens work. You can expect $$anonymous$$or changes in reported touch positions.
Thanks. I was using the delta position to send '$$anonymous$$ouseUp' events to the object the touch was previously over. I am now storing these previously touched objects in an array so I don't need to rely on the delta position.
Answer by asianfanfics68 · May 02, 2019 at 10:17 AM
Oh, great, your article gives me useful information and a fresh perspective on the subject.
Your answer
Follow this Question
Related Questions
Unity Remote 3 and accessing multiple Input.touches? 3 Answers
Tracking Touch Points on Screen for Mobile Devices 1 Answer
Rotate camera with iOS touch 1 Answer
How to centre a 3D pinch zoom 1 Answer