Android Touch input and what it means for you

This post is mostly to help you avoid the annoying pitfall we fell into with Touch.deltaPosition.

I was working on making our game (Battle Bears Blast) work for Android after iOS and I noticed an awful issue with the crosshairs not moving to the current touch position during/after a lag spike. Even with small lag spikes, if moving the crosshair, the crosshair would stop moving with your finger still sliding across the screen. What we were using was:

Input.touches[0].deltaposition

The fix was caching our own previous touch and current touches, then calculating our own “delta”. Implementing this simple idea made our game work very well and stopped the random loss of control of the crosshair.

I think how the Touch.deltaPosition works is that it doesn’t actually update every frame. Instead, it’s like a volatile input that changes any time (again, I’m obviously not sure, but this is what I THINK the issue is). So by using our calculated “delta”, we ensure that our controls are done on a frame-by-frame basis.

Anyways, let me know what you think. Any comments, ideas, suggestions, etc are welcome.

-Marc

thnx for the nice post.
Do you know how to approach raycasting on a tablet. It seems that my program doesnt respond to that when I pput on my tablet.
Do I have to include something like Input to make it work on the tablet (android).