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

The curious case of Input.GetTouch(0)

Discussion in '2D' started by geek_freek, Feb 9, 2016.

  1. geek_freek

    geek_freek

    Joined:
    Aug 26, 2014
    Posts:
    51
    I have been working on my game recently where i decided to use Android as the platform . I implemented a swipe detection for the game that changes player direction. Now to detect a touch event i used Input.GetTouch(0) since i only needed one touch to go about everything(multi-touch not required). Created a prototype build few days back , touch worked perfectly on my Android Phone. Built the same code with a few updations into my UI and the Input.GetTouch(0) has stopped working on the same phone.

    FYI:-When i test the game through UnityRemote 4 touch is detected on my phone.
     
  2. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    can you revert to the previous build? if so load that one back on to the phone & see if it still works. Maybe your phone received an update between your two tests?
     
  3. geek_freek

    geek_freek

    Joined:
    Aug 26, 2014
    Posts:
    51
    I'll try that when i reach home. There is one more thing i noticed but forgot to put that down. I am also cheking for a double tap which uses Input.GetTouch(0).tapCount . This is working fine.

    i have a MainControlller class where the functions are defined as:-

    Code (CSharp):
    1.  
    2. class MainController{
    3. .
    4. .
    5. .
    6. .
    7. .
    8. public bool doubleTapCheck(){
    9. //Checking Input.GetTouch(0).tapCount
    10. }
    11.  
    12. public int SwipeDirectionX()
    13. {
    14. //Store Input.GetTouch(0) in a Touch variable
    15.  
    16. //Logic for checking Swipe Direction and returning //the results.
    17. }
    18. }
     
  4. geek_freek

    geek_freek

    Joined:
    Aug 26, 2014
    Posts:
    51
    Well I got this working.
    Switched platform to some other platform in build settings , switched back again to Android . Created a build and things were working .