News: Enjoy our Christmas offer 30% off on our latest package Tower Defense Level Kit http://u3d.as/m7h

  • October 18, 2018, 06:07:38 PM

Login with username, password and session length

Author Topic: swipe speed independ of screen size/resolution  (Read 8127 times)

Offline wouter_vugt

  • Newbie
  • *
  • Posts: 23
swipe speed independ of screen size/resolution
« on: February 19, 2015, 10:56:16 PM »
I use easy touch in order to rotate, zoom and pan my camera.
However I have to change mij rotation, zoom and pan speed on each device (due to different resolutions and screen sizes).

But I want a system that works the same on each device, independ of resolution or screen size, so that the user experience
remains the same on each device (and is not super slow on one and super fast on another).

How does this work? I hope your not gonna tell me this is not supported?

hope to hear from you,
Wouter

Offline Nicolas

  • Administrator
  • Hero Member
  • *****
  • Posts: 792
Re: swipe speed independ of screen size/resolution
« Reply #1 on: February 20, 2015, 08:51:02 AM »
Hi,

Like Unity API (deltaposition etc...) , Easytouch return  all values  in pixel. Because there are several techniques to standardize values, and to avoid unnecessary calculations based on what you want.

some possibilities :
1- Simply divide the value by the result of Screen.dpi function. (Test before if Unity return a value greater than 0 for Screen.dpi)
2- Simply divide the value by the maximum screen resolution.
3- calculate the hypotenuse of the screen size, and use as a divider of the first solution
etc..














Offline wouter_vugt

  • Newbie
  • *
  • Posts: 23
Re: swipe speed independ of screen size/resolution
« Reply #2 on: February 20, 2015, 03:22:56 PM »
Hi,

Like Unity API (deltaposition etc...) , Easytouch return  all values  in pixel. Because there are several techniques to standardize values, and to avoid unnecessary calculations based on what you want.

some possibilities :
1- Simply divide the value by the result of Screen.dpi function. (Test before if Unity return a value greater than 0 for Screen.dpi)
2- Simply divide the value by the maximum screen resolution.
3- calculate the hypotenuse of the screen size, and use as a divider of the first solution
etc..

Well the dpi doesnt seem to work on windows phone...
is there not some simple way to detect the actual velocity of the finger (m/sec) for example, so it would work across all screens?

I think otherwise the dpi would be perfect, I dont understand your other solutions, could you clearify them or give my another option.
I woul really appreciate it.

I think anything you would do on screen resolution, will not work since screen resolution and size and not the same on each device...?
(a device that is 1920 pixels wide, can either be a phone, tablet or tv screen. and swiping across half of them, on a telephone is a small swipe, and on a tv screen is a very large swipe (so on the tv the swipe would be much slower than a telephone) and this is the problem I want to fix. So that the swipe sensetivity is the same on any device you use it on.

I think this would require knowing the size of the screen, that's why the dpi must work. but it doesnt seem to work on all devices, at least not on my windows phone.. hope this clarifies what im tryin to achieve.
« Last Edit: February 21, 2015, 12:05:44 PM by wouter_vugt »

Offline wouter_vugt

  • Newbie
  • *
  • Posts: 23
Re: swipe speed independ of screen size/resolution
« Reply #3 on: February 22, 2015, 08:46:10 PM »
also is it maybe an idea to use Camera.ScreenToWorldPoint in order to base the swipe speed on the game world and in that way get a universal speed (not changed by resolution or screen size)? and would I go about doing this?

Offline Nicolas

  • Administrator
  • Hero Member
  • *****
  • Posts: 792
Re: swipe speed independ of screen size/resolution
« Reply #4 on: February 23, 2015, 07:51:34 AM »
If Screen.DPI doenst work, so just divide the value by Screen.width. That all

Offline wouter_vugt

  • Newbie
  • *
  • Posts: 23
Re: swipe speed independ of screen size/resolution
« Reply #5 on: February 23, 2015, 11:04:22 AM »
If Screen.DPI doenst work, so just divide the value by Screen.width. That all

please read my posts...
anything that uses screen resolution does not work!

since a mobile phone with a small screen van have full hd resolution, and a tablet with a much larger screen can have full hd as well.
Which would mean that swipe speed would be slower on the tablet and faster on the phone (since the distance between the pixels would be bigger on the tablet and smaller on the phone). so the same amount of pixels would translate to a longer physical distance on the tablet vs the phone.
What I want is that  the resolution is independent, and a swipe of 2sec travelling say 5cm, would give the same speed independent of resolution and screen size.

There must be a solution for this, please read my posts and respond. I am willing to write a good review on the asset store if you would help me with this.

please see this (finger gestures does use this)
http://fingergestures.fatalfrog.com/docs/manual:dealing_with_dpi
« Last Edit: February 23, 2015, 11:13:04 AM by wouter_vugt »

Offline Nicolas

  • Administrator
  • Hero Member
  • *****
  • Posts: 792
Re: swipe speed independ of screen size/resolution
« Reply #6 on: February 23, 2015, 03:44:04 PM »
DPI
To do that you want, you need the DPI value,but  I can't help you  if Unity doesn't return a correct value for Screen.DPI for Window phone as you saided.  First you must raise a bug erport to Unity for Screen.DPI on Window Phone

Fingers gesture uses the DPI value  return by Unity, it will have the same issue ....
On your link on the documentation "based on the current device's screen DPI"

So the only solution that you have it is to work with normalized length (but you will have some little difference).
Normalize length = swipe length / max screen size
Speed  = normalize length / action time

For your idea to take the 3d world in reference
1 -  convert  startposition & position from swipe to 3d coordinate with the function GetTouchToWorldPoint from Gesture class
2 - Compute the length with Vector3 distance
3 - Divide the result by  actionTime property of gesture class.

Code: [Select]
private Vector3 startPosition;

void On_SwipeStarrt (Gesture gesture){
      startPosition = Vector3.Distance( gesture.GetTouchToWorldPoint(10));
}

void On_SwipeEnd (Gesture gesture){

    Vector3 distance= Vector3.Distance( gesture.GetTouchToWorldPoint(10) - startPosition );
     float  Speed =  distance / gestion.actionTime;
}

But this solution is relative to your 3d world...














Offline wouter_vugt

  • Newbie
  • *
  • Posts: 23
Re: swipe speed independ of screen size/resolution
« Reply #7 on: February 24, 2015, 05:18:51 PM »
DPI
To do that you want, you need the DPI value,but  I can't help you  if Unity doesn't return a correct value for Screen.DPI for Window phone as you saided.  First you must raise a bug erport to Unity for Screen.DPI on Window Phone

Fingers gesture uses the DPI value  return by Unity, it will have the same issue ....
On your link on the documentation "based on the current device's screen DPI"

So the only solution that you have it is to work with normalized length (but you will have some little difference).
Normalize length = swipe length / max screen size
Speed  = normalize length / action time

For your idea to take the 3d world in reference
1 -  convert  startposition & position from swipe to 3d coordinate with the function GetTouchToWorldPoint from Gesture class
2 - Compute the length with Vector3 distance
3 - Divide the result by  actionTime property of gesture class.

Code: [Select]
private Vector3 startPosition;

void On_SwipeStarrt (Gesture gesture){
      startPosition = Vector3.Distance( gesture.GetTouchToWorldPoint(10));
}

void On_SwipeEnd (Gesture gesture){

    Vector3 distance= Vector3.Distance( gesture.GetTouchToWorldPoint(10) - startPosition );
     float  Speed =  distance / gestion.actionTime;
}

But this solution is relative to your 3d world...

thank you!

well what I do now, if unity doesnt get any dpi, I simply use a guessed screen size(4.5inch) and based on the resolution of the device calculate a DPI value myself.

So for phones which are all around 4inch, this should work ok. (it is a better guess than just using a static dpi).
however for tablets this doesnt work as well, and I have no way of detecting wether someone uses a tablet or phone.

Hopefully unity will fix this in the future.

Offline wouter_vugt

  • Newbie
  • *
  • Posts: 23
Re: swipe speed independ of screen size/resolution
« Reply #8 on: February 25, 2015, 03:24:57 PM »
One more question:
should I multiply deltaPosition by deltaTime?

this(what i use now):
yDegIdial +=  gesture.deltaPosition.y * orbitSettings.rotationSpeed;

or:
yDegIdial += Time.deltaTime * (gesture.deltaPosition.y * orbitSettings.rotationSpeed);
or some other combination, maybe divide by deltaTime?

I would think not, since if i move it 10 pixels in 2 seconds, it should not normalise the time?


Offline Nicolas

  • Administrator
  • Hero Member
  • *****
  • Posts: 792
Re: swipe speed independ of screen size/resolution
« Reply #9 on: February 26, 2015, 03:15:24 PM »
Hi,

Delta position is computed when the event is fired, so for me you don't have to multiply by deltaTime.

Offline wouter_vugt

  • Newbie
  • *
  • Posts: 23
Re: swipe speed independ of screen size/resolution
« Reply #10 on: February 26, 2015, 04:11:42 PM »
Hi,

Delta position is computed when the event is fired, so for me you don't have to multiply by deltaTime.

I dont get that.

Could you explain about how this works?

Offline Nicolas

  • Administrator
  • Hero Member
  • *****
  • Posts: 792
Re: swipe speed independ of screen size/resolution
« Reply #11 on: February 27, 2015, 12:54:56 AM »
DeltaTime must use when you want to use move an object to a speed, the delta allow to take into account the render time of the last frame.
For exemple if you want to move an objet to 10 Unit per seconde, you must multiply 10 * Time.Deltatime.

But deltaposition is value since the last change, it isn't a speed.