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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

speed of Input.Gettouch vs OnPointerdown

Discussion in 'Scripting' started by jackson_31, Sep 19, 2016.

  1. jackson_31

    jackson_31

    Joined:
    Sep 20, 2014
    Posts:
    84
    I understand there are two ways of getting touch input: using get touch or on pointer down.

    is there any speed advantage of one over the other? I have a working input using get touch but there seems to be at least 500 ms lag between the time I touch the screen and the character moving. I am using Galaxy Note 5. So now I am trying to do it with OnPointerDown. However if there will be the same lag I will not waste my time.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,797
    Instead of "getting the character to move," why don't you turn on and off a single UI Text object based on when you touch the screen and see if the lag is really in the input mechanism you choose, or perhaps in the animator that makes the character move.

    Remember also that the Unity Input system offers various forms of low-pass filtering which can also slow your apparent responsiveness down. They do this to smooth out input controller noise, but you can also get at the raw values, generally speaking.
     
  3. xdotcommer

    xdotcommer

    Joined:
    Aug 20, 2014
    Posts:
    33

    Did you ever figure this one out?
     
  4. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,732
    I've never noticed any major input lag when using GetTouch on mobile devices (Android).

    I seem to remember that using OnPointerDown generated a compiler warning that it wasn't ideal to use it for mobiles and recommended using GetTouch instead, although there again I don't recall seeing any visible difference myself.

    If you're getting input lag I'd suggest the problem lies elsewhere in the code.