4
\$\begingroup\$

I have drag mechanic in Unity game and I want to have same experience in all devices. I've done this before in another game engine and now that Unity gives us Dpi with Screen.DPI, it should be much easier to achieve, but I can't figure it out for the love of the god.

My theory is you have to divide the delta movement of touch with Screen.Dpi to normalize the movement and make it same across devices with different screen sizes and dpi's:

(touch0.deltaPosition.x / dpi) * SENSITIVITY * Time.deltaTime;

But this doesn't work. Would someone please tell me why?

I've done extensive search on this but surprisingly nothing much can be found.

Thanks in advance and regards.

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

If I understand correctly, the issue you are having is finger movement not translating perfectly to pixel movement. The solution which worked for me came from the accepted answer to this post: Android Touch Variation Correction? (How to use Screen.dpi?)

Passing the Touch object into the FixTouchDelta() function made it work correctly.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .