Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Problem with TouchPhase.Began and deltaPosition

Discussion in 'Android' started by ladron, May 4, 2012.

  1. ladron

    ladron

    Joined:
    Mar 16, 2012
    Posts:
    47
    I'm having some issues with touch input under Android. I'm getting weird values for deltaPosition - they are too small - and I'm not getting any touches with TouchPhase.Began at all.

    Anyone else seeing this? I'm using a Kindle Fire.
     
  2. ladron

    ladron

    Joined:
    Mar 16, 2012
    Posts:
    47
    Oops - just after I posted, I realized that the TouchPhase.Began issue was my fault. It seems to be working fine.

    I still have issues with deltaPosition, though.
     
  3. mwk888

    mwk888

    Joined:
    Jan 26, 2014
    Posts:
    16
    I fought with Touch.deltaPosition on Android for quite a while building a pan/zoom touch UI. I wanted reliable measurements so I can calibrate the pan/zoom effect to exact distance on screen at Screen.dpi.

    I was never make Touch.deltaPosition work reliably, I could not find a compensation methods that made the cummulative deltaPosition equal the total distance traveled across a range of devices. One approach I tried but could not make reliable was http://answers.unity3d.com/questions/209030/android-touch-variation-correction.html

    (My theory: On Android the native touch UI can generate events much faster than frame rate to give higher resolution motion tracking; I wonder if the Input touch API just keeps the last event per frame?)

    My solution was to stop using deltaPosition. Instead I did a simple state machine that samples start position when the touch begins and then manually computes delta relative to that start position each Update. That works fine and didn't really add complexity as I needed stateful UI logic anyway.
     
unityunity