- Home /
touch input error - finger position offset
At various random times the remote will not track fingers correctly and will offset the input by as much as an inch. This happens when running by app in Unity and after building it to my iPad (and previously to my iPhone).
I've been having this trouble since I started programing with Unity over a year and a half ago and I keep thinking it must be something I'm doing wrong (though I suppose it's possible that it's a bug). I'm running the latest release version of Unity, SDK, and Snow Leopard.
Usually I can fix it by quitting Unity and restarting. However, it happens often enough that I may have to quite Unity every time I run my app. It usually follows a code update, but I haven't noticed a pattern as to what JavaScript is affecting it.
I could live with this, annoying as it is, but now I can't get my builds to work, even when the app works with the remote. I've spent the last 2 hours continually quitting Unity, opening it, building my app, installing it, finding out it is still not registering my finger touch under by finger, but about and inch away, and starting the process over.
Have you considered making a calibration scene on your game to let player set their own controls and touch position? It's possible that not all devices are the same and it'd fix your offset problem.
I'm only going to build for the iPad, so that eli$$anonymous$$ates platform variences. I think it's an issue of why the raycast isn't registering my finger correctly. Here's the relevant code [sorry,I can't find any code block setting in the comment input]:
touch = iPhoneInput.GetTouch(0); var ray = Camera.main.ScreenPointToRay(touch.position); var hit : RaycastHit; if (Physics.Raycast(ray, hit) { hitObject = hit.transform.gameObject; }
I have been able to get it working and each time the last thing I tried was changing the iPhoneSettings.screenOrientation. The previous time it worked (after I posted the question) I changed it to Landscape. This time (after leaving my comment) I changed it to to Portrait then back to Landscape and finally back to Portrait before it worked. (The orientation setting doesn't affect my game, which is oriented by turning the iPad, as you would with a printed boardgame, so I don't have any reason to choose one orientation over the other.)
Answer by sharmoni · Aug 07, 2010 at 10:52 PM
Well, as far as I can tell I solved this. Because my camera was continually changing position it was freaking out the raycast. I was getting too many readings. I resolved it by moving the Physics.Raycast part of the script to the script that was moving the camera. So every time the camera moved it would recast the ray.
Answer by sharmoni · Jul 17, 2010 at 10:45 PM
Ok, looks like I sorted this one out. I was using my main camera to register taps on objects. That camera is on a joint so it swings around above the board to match the tilt of the iPad. The camera position was offsetting the raycast. Once I had a static camera to use for my GUI buttons, I set the raycast to use that camera and it's been trouble-free ever since. Hope this helps someone else.
And no, that just caused the same problem. I'm not getting a correlation between where I touch in the screen view and the object in the world space. If anybody reads this who understands the various ray hit options I would appreciate some recommendations.
Your answer
Follow this Question
Related Questions
How I make finger touch move texture offset 0 Answers
Mobile game Player follow finger input problem (C#) 2 Answers
GUI texture touch to input 1 Answer
object falow finger problem ? 4 Answers