Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct here to familiarize yourself with the rules and how to post constructively.

  2. Unity 2022.1 is now available as the latest Tech release.
    Dismiss Notice
  3. Improve your project's performance with our new guide on profiling in Unity.
    Dismiss Notice

Touch position not recognized by any android devices.

Discussion in 'Editor & General Support' started by Whiplash, Feb 16, 2012.

  1. Whiplash

    Whiplash

    Joined:
    Dec 14, 2011
    Posts:
    6
    I've been banging my head against the monitor for the better part of a week trying to get a 3D button clickable (or touchable, i suppose) for android. Putting function OnMouseUp() works fine when testing it in the editor, but doing something like; for (var touch : Touch in Input.touches) if (touchphase.ended) etc etc, has no effect.

    But then I red TouchPhase.Ended was a bit unreliable, so I did a simple workaround, something like;
    if (touch stationary)
    touchPos = touch.position;
    holding = true;

    if (Input.touchCount == 0 holding)
    holding = false;
    // collider.raycasting

    and further I did a raycast from the main camera to the object the script was attached to, from the screen coordinates (using the formentioned variable touchPos). Yet again though, it doesn't work.

    And this is where I am stuck. Trying to get the touch position seems to be the hazzle, and much of this code is taken straight from the documentations. I just don't get it, what am I doing wrong?

    Oh and by the way, I don't think this is a noob issue. I've of course checked the code for bad spelling, I don't get any errors running it, and I've tried every single way I can think of, not to mention Input.GetTouch. It just won't registre the touch position, it appares.

    Any help would be greatly appreciated :)
     
unityunity