Search Unity

touch.deltaPosition periodic chaos!

Discussion in 'Scripting' started by ADNCG, Jan 20, 2022.

  1. ADNCG

    ADNCG

    Joined:
    Jun 9, 2014
    Posts:
    994
    I'm experiencing an issue where touch.deltaPosition periodically seems to be mismatching and causes stutters. This happens for a few seconds and then goes back to normal.

    Culprit is not performance issues. App is getting a steady 60 FPS with no frame deltas reported above 0.02. I've tried replacing the movement function with a sine wave instead of an offset based on input and the stutters are gone, hence I am pretty confident the issue resides there.

    The issue happens on iOS, we have a live build on android and no issues reported. It seems to be worse with higher res/larger devices. For instance, the issue does not seem to occur on iPhone 8. Can be observed on iPhone X but at a lower degree and is very noticeable on iPhone 12 pro max.

    The input code is as basic as fetching the touch where fingerId == 0, taking its deltaPosition.x component, dividing it by the screen width and multiplying by some constant. This forms an offset that I then add to the player's x position.

    I'm having issues finding others who have experienced something similar. Been at this for a day, I welcome all ideas with open hands

    edit : Same results with the new input system
     
    Last edited: Jan 20, 2022
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    EDIT: disregard below, I just realized you said you are seeing this on multiple pieces of hardware.

    Disregard:

    Do you have any drawing program installed to try and drag your finger around and test it there? That might check if your ipad is having some kind of issue that you only notice in your game.

    And as always, reboot the ipad... they do leak RAM and ultimately crash. :)
     
  3. ADNCG

    ADNCG

    Joined:
    Jun 9, 2014
    Posts:
    994
    Yeah, it's unfortunately not the device :( but thank you anyway!
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,745
    I like that you threw in a sine wave simulation to prove everything downstream.

    But did you also put in something to visualize the touch at the point you capture it from Unity?

    If you did that and it was erratic you could actually file a good bug with that code and steps to repro on ios.

    It might also flush out one more little corner of "wtf?!" between where the touch is accepted and where it is used. :)
     
  5. ADNCG

    ADNCG

    Joined:
    Jun 9, 2014
    Posts:
    994
    Hey, thanks for the reply!

    I had a vertical bar at the input's x position since I'm only interested in the x. It seemed to suffer the same hiccups. Not sure how deltaPosition is assigned internally but if it's just curPos - lastPos, taken from touch.Position, then yeah deltaPosition is working as intended and touch.position is guilty.

    I might investigate further and push a bug report but currently the game should have been in QA's hands yesterday and I am making a lot of people nervous.

    Currently attempting to downgrade to 2019.4.34 and see if that resolves anything

    edit : No luck downgrading. Going to try to upgrade to whatever the 2021 version is on the hub

    edit2 : Just tried a barebone project while installing and it works as intended... I have nothing else that affects the player's position in my main project. Investigating...
     
    Last edited: Jan 20, 2022
    Kurt-Dekker likes this.