I’m tinkering for the first time with the touch screens of the latest generation of iPad and iPodTouch devices. I have a simple test app with a gameObject’s position updated to match the x y location of the Input.GetTouch(0).position each Update().
When setting the position of the object there seems to be noticable lag between my finger position and the object’s position (with the object catching up over a couple of frame updates).
Games like Fruit Ninja appear to have snappier touch detection. Is this a known Unity issue, or do I need to do something arcane with the fixedUpdate frame rate stuff (which I haven’t dabbled yet)?
I get the same lag from Input.touches[0] or Input.GetTouch(0) (single finger touch, so I’m not reading off the wrong end of an array).
Changing Update() to LateUpdate() does not seem to help the problem. Also, fresh touches (taps) seem to update snappier than dragging touches.
I was getting 30fps, and it seemed to have a 1 to 2 frame lag at least on a single finger drag. I did find out today about editing the obscure kFPS constant and now get 60fps which certainly helps obscure the delay, but it still feels some way off Fruit Ninja. (no I’m not cloning it, just an example ). And a lot of advice on the forums seems to say lock to 30fps In any case to keep the fps constant.
There were some interesting code comments in the class where you edit the kFPS regarding input lag, but I’m not knowledgable enough to understand the details. Thanks for your attention so far.
Best practice is still using Input.GetTouch in an Update() call from what I could tell?
if you need low latency, you need to change the type of input handling loop in the xcode project away from the standard which is targeted at “continous smoothness with as little frame impact as possible”, you might want a more interupt alike behavior which priorizes input over “continue on next frame”
Also, I don’t see why GetTouch should be best practice. Best practice would be usage of Input.touches
it would especially sound silly that it allocates anything given it returns an array reference which is stored statically on a class and that by naming scheme is not a property but a real variable.