I’m using Input.GetMouseButton(0) to detect touches, but sometimes it will continue to return true even after you have let go.
It only happens rarely, but I can’t seem to find any sort of reproduction steps. I’ve noticed some weirdness when you gesture on and off the edges of the display, but this happens even if you stay well inside the screen boundaries.
Has anyone else experienced this? Are there any solutions?
Could it possibly be related to poor performance, causing it to miss the release events?
Thanks in advance.
[edit]
I’m calling GetMouseButton(0) during an Update() function, and we’re using the NSTimer main loop.
same problem here, i mentioned it in this thread http://forum.unity3d.com/viewtopic.php?t=34441 but got no reply… its only happening after i drag around with the finger a little bit on the screen and when i lift the finger iPhoneInput.touchCount is 1. Its random.
…why aren’t you using touch events. Regardless of the compatibility with GetMouse why not test with events first?
I have stacked my controls with touch events for all sorts of detection from swipes to taps to double taps to rotations to raycasts and they NEVER fail, so just give that a shot.
Now if I’m talking out of my ass and indeed it’s identical in usage, then there has to be something else in your code keeping the boolean from switching.
See what bumba said, it happens with touches, too.
It has nothing to do with my code. There’s nothing I can do to influence the response I get from Input.GetMouseButton(). It should return true when there is a press, and false when there’s not. This isn’t happening, and bumba has confirmed that I’m not alone here.
No I saw that, and regardless I’m assuming both of your pieces of code are different; in your case try touchEvents.
Now lemme ask this…do you guys sometimes drag OFF the screen (accidentally lets say)? I’ve noticed false positives with this but it’s rare. Dragging into other defined ‘touch zones’ doesn’t have this effect so beyond that I couldn’t imagine what it is, as again I’ve loaded up my events and they work 99.9% of the time (again the off-screen drag issue).
I have only noticed it in one project, but this is the only project that uses gestures extensively. If it was happening in other projects then I probably wouldn’t know.
its definitely a Unity Bug. I try to reproduce it with a very small scene(only camera and a script). What i do:
i drag around my finger(from left to right and back, several times) on Landscape.Right modus mostly in the left corner. iPhoneInput.touchCount is always working good but sometimes(very random behaviour) it stays 1 after i lift my finger.
Important: After that random behaviour i start the scene again without touching the screen and : TouchCount stays 1!! It worked again after i touch the screen and lift my finger it goes to 0. Maybe this will help he unity guys to solve this issue.
note: i printed out iPhoneInput.touchCount, iPhoneInput.touches[0] and Phase.
Just want to chime in and say that I have definitely come across this problem in my game from time to time. I’ve tried a number of fixes and not sure which one is currently solving it… srry for the horrible QA job.
i dont know, maybe unity doesnt poll every frame for iphoneinput events …i tried to play around with kMillisecondsPerFrameToProcessEvents(allows you to specify how much time you allow to process events if OS event pump method is used) but it doesnt affect much