Search Unity

No touch position (android)

Discussion in 'Input System' started by skirners1, Aug 8, 2020.

  1. skirners1

    skirners1

    Joined:
    Sep 4, 2014
    Posts:
    9
    Hello!

    I can't get positions from my touches on the screen. I get the amount of touches, but no phases or positions.
    If I use the old Input, it works as intended.

    Here is my code (sorry for the bad formatting, I’m writing from a phone):

    Code (CSharp):
    1.  
    2. Update(){
    3.  
    4. ts = UnityEngine.Experimental.Input.Touchscreen.current;
    5.  
    6. int num = ts.activeTouches.Count;
    7.         Vector2 pos3;
    8.  
    9.         if(num > 0)
    10.         for(int i = 0; i < num; i++)
    11.         {
    12.             pos3 = ts.allTouchControls[num].ReadValue().position;
    13. print(i + "   " + "pos3: " + ts.allTouchControls[i].ReadValue().position);
    14. print(i + "   " + "phase: " + ts.allTouchControls[i].ReadValue().phase);
    15. }
    16.  
    17. int num2 = Input.touchCount;
    18.         Vector2 pos5;
    19.  
    20.         if(num2 > 0)
    21.         {
    22.  
    23.             for(int i = 0; i < num2; i++)
    24.             {
    25.                 pos5 = Input.touches[i].position;
    26.  
    27.                 print(i + "   " + "Input.position: " + pos5);
    28.                 print(i + "   " + "Input.phase: " + Input.touches[i].phase);
    29.  
    30.             }
    31.         }
    32. }
    What am I doing wrong?

    Edit. I’m using Unity 2018 LTS and the experimental input system. (So I can get rid of the latency from the old one on Android devices.)

    BR
    /Lucas
     
    Last edited: Aug 9, 2020
  2. skirners1

    skirners1

    Joined:
    Sep 4, 2014
    Posts:
    9
    This is now fixed. I upgraded to 2019 LTS. That also solved my headache with Unity IAP :)

    It doesn’t weigh up enough for all the headache, to give ‘good job’ shout out ;-)