Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Unity 2022.2 is now available as the latest Tech release.
    Dismiss Notice
  3. We are making some changes to the DOTS forums.
    Dismiss Notice
  4. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

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,022
    Could you please submit a bug report with a minimal reproduction project for this issue?
     
  3. mwlazlo885

    mwlazlo885

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

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,022
    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:
    398
    Hi did you solve this issue? I am facing the same problem.