Touch.deltaPosition issues

I’m trying to use Touch.deltaPosition to move a camera around an object when panning with a finger. The problem I’m having is that my iPad is getting much higher values than my Android devices, but they don’t seem to correlate with the DPI of the devices

I’ve set up a test where it adds up the delta positions as I pan across the whole device. These are the results I get:

iPad Air:
Width: 2048px
DPI: 264
Maximum Result: Close to 2048

Galaxy S7 Edge:
Width: 2560px
DPI: 534
Maximum Result: Around 320

Galaxy S4:
Width: 1920px
DPI: 441
Maximum Result: Around 310

A theory that I have is that maybe the delta position is
being calculated at 30fps, and your game runs at 60fps ( or reverse) and that every delta position is being applyed 2x

Or maybe you just are not converting screen coordinates into world coordinates.

Are you sure the inputs are recording at the same polling rate? Check the touch delta time.

I have the game capped at 30fps. The deltaTime on the iPad seems to be around 0.033, and on the Galaxy S7 Edge/Galaxy S4, anywhere from 0.001 to 0.01

This seemed to work pretty well for me:

float value = touch.deltaTime > 0 ? touch.deltaPosition.x / Screen.width / touch.deltaTime : 0;

is there another way to fix it?

Yes, create your own thread rather than necroing a super old post.

2 Likes