Search Unity

Lag with input touches, Unity3d problem?

Discussion in 'Scripting' started by celaeno, May 30, 2013.

  1. celaeno

    celaeno

    Joined:
    Jan 31, 2013
    Posts:
    64
    Hello, I'm making a path drawing game and experiencing some lag with the input touches.

    Sometimes you get a big gap between the points, when you quickly swipe a circle. I couldn't find the reason for this, so I tested it on the normal android SDK and experienced a much more fluently touch input. Does anyone know if this a Unity3D related problem, or am I doing someting wrong? Below you can see the screenshots(i can;t manage to place them right here due to some bugs with posting images on the forum, so scroll a litte downwards in my post to see them). Also I provided some code and hope someone knows a solution for this :)


    Code (csharp):
    1.  
    2. function Update ()
    3.  {
    4.  if(Input.touchCount == 1)
    5.  {
    6.  // touch on screen
    7.  if(Input.GetTouch(0).phase == TouchPhase.Began)
    8.  {
    9.  pos = Input.GetTouch(0).position;
    10.  ray = Camera.main.ScreenPointToRay(pos);
    11.  
    12.  if (Physics.Raycast (ray, hit, 50) )
    13.  hit.transform.gameObject.SendMessage("TouchBegan") ;
    14.  }
    15.  
    16.  
    17.  if(Input.GetTouch(0).phase == TouchPhase.Moved)
    18.  {
    19.  
    20.  pos = Input.GetTouch(0).position;
    21.  // pos = Camera.main.ScreenToWorldPoint(pos);
    22.  hit.transform.gameObject.SendMessage("TouchMoved", pos);
    23.  
    24.  
    25.  }
    26.  
    27.  
    28.  
    29.  if (Input.GetTouch(0).phase == TouchPhase.Ended || Input.GetTouch(0).phase == TouchPhase.Canceled)
    30.  {
    31.  
    32.  hit.transform.gameObject.SendMessage("TouchEnded") ;
    33.  
    34.  }
    35.  }
    36.  
    37.  }
    38.  

    The first screenshot is from Unity, the second is from Android:
     

    Attached Files:

    Last edited: May 30, 2013
  2. TheRaider

    TheRaider

    Joined:
    Dec 5, 2010
    Posts:
    2,250
    are you using the remote? if so test on device.
     
  3. celaeno

    celaeno

    Joined:
    Jan 31, 2013
    Posts:
    64
    These are screenshots from a real device, no remote.