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. Dismiss Notice

Touch registers as Input.GetAxis("Mouse X") & Y -- Can I STOP that???

Discussion in 'Editor & General Support' started by infinitypbr, Jan 15, 2016.

  1. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    3,149
    Alright -- it seems that by default, touch input registers as Mouse X and Mouse Y Inputs.

    This means that code which rotates a camera with mouse movement will ALSO be activated when a finger touches the screen.

    From what I've found, the "answer" is to get rid of the mouse code on mobile devices...But I'd like for this to have both, since some devices also allow mice -- like some of the modern touch tablets or laptops with touch screens.

    Is there a way to simply turn this behavior off??
     
    Last edited: Jan 15, 2016
  2. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    3,149
    Updated Question
     
  3. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    You can check if Input.mousePresent is true and if not disable the usage of Input.GetAxis("Mouse X") & Y.
     
    infinitypbr likes this.
  4. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    3,149
    Thanks! That's similar to what I ended up doing. It took 2 hours of playing an old 90s game for my brain to figure it out :) But the mobile joystick script will change a boolean on the player movement script to "touching = true" if a finger is being touched, which make the movement script ignore the Axis data.
     
  5. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    That would be what i have done in previous versions of unity (not sure since when Input.mousePresent is available)
    Good that you found a solution.
     
    infinitypbr likes this.
  6. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    3,149
    Actually, you've helped me out -- I didn't know about Input.mousePresent, and just now I needed to find out if a mouse was present for another bit of code -- so thanks!