Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Touch delta position for both legacy and new input systems returning wrong values

Discussion in '2020.1 Beta' started by JakHussain, Apr 29, 2020.

  1. JakHussain

    JakHussain

    Joined:
    Oct 20, 2016
    Posts:
    318
    I have a project in 2019 using the following code:

    Legacy:
    Code (CSharp):
    1. if (Input.touchCount == 1 && Input.GetTouch (0).phase == TouchPhase.Moved)
    2. {
    3.     eulerRotation.y += Input.GetTouch (0).deltaPosition.x * touchSensitivity;
    4.     eulerRotation.x -= Input.GetTouch (0).deltaPosition.y * touchSensitivity;
    5.  
    6.     eulerRotation.x = Mathf.Clamp (eulerRotation.x, -90f, 90f);
    7. }
    New:
    Code (CSharp):
    1. if (Touch.activeTouches.Count == 1)
    2. {
    3.     if (Touch.activeTouches[0].phase != UnityEngine.InputSystem.TouchPhase.Began)
    4.     {
    5.         eulerRotation.y += Touch.activeTouches[0].delta.x * touchSensitivity;
    6.         eulerRotation.x -= Touch.activeTouches[0].delta.y * touchSensitivity;
    7.  
    8.         eulerRotation.x = Mathf.Clamp (eulerRotation.x, -90f, 90f);
    9.     }
    10. }
    And I get completely expected behaviour which is that I can drag my finger across the screen to rotate my camera around a target and if I lift my finger and touch somewhere else on the screen, it just continues as normal.

    As of the latest 2020.1 beta, when I lift my finger and continue dragging on a different part of the screen, the delta value spikes to be equal to the distance my finger travelled while OFF the screen. This results in my rotation snapping to the value it would've been at had I not lifted my finger at all.

    Since this wasn't an issue in 2019, the issue can be found on both input systems AND using the device simulator package in the editor doesn't produce the same results, I would peg this as a bug. But I wanted to post here in case I was missing something.

    This issue can be found on Android builds. I can't test on iOS.
     
  2. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,143
    Could you please submit a bug report with a minimal reproduction project for this issue?
     
  3. mwlazlo885

    mwlazlo885

    Joined:
    May 17, 2018
    Posts:
    7
    is this fixed? Ive got the same issue.. on iOS problem exist too..
     
  4. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,143
    Please submit a bug report if you're experiencing problems. Information on what devices the issue reproduces and a reproduction project would be useful for an investigation. Based on the information in this thread alone we weren't able to reproduce the behaviour.
     
  5. saifshk17

    saifshk17

    Joined:
    Dec 4, 2016
    Posts:
    488
    Hi did you solve this issue? I am facing the same problem.