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

  • September 24, 2018, 03:24:16 PM

Login with username, password and session length

Author Topic: Retina Gesture.deltaPosition  (Read 5009 times)

Offline vsn3e8

  • Newbie
  • *
  • Posts: 6
Retina Gesture.deltaPosition
« on: May 01, 2013, 07:16:38 PM »
Hi,

I had a question on the unity forums in regards to gesture.deltaPosition and retina displays.

My question was essentially if there existed a configuration setting or something to enable which detects automatically pixel density and returns delta positions that automatically factor in the density to screensize ratio, rather than explicitly having to multiply oneself.

Currently I'm using this value to pan a camera, and would like the camera to move at the same speed as the gesture itself. In order to achieve this result on retina, i have to scale deltafactor by a factor of 2. Since the screen height is the same on an ipad vs retina ipad, even though retina has a density that's twice as large.


Offline Nicolas

  • Administrator
  • Hero Member
  • *****
  • Posts: 792
Re: Retina Gesture.deltaPosition
« Reply #1 on: May 01, 2013, 07:45:48 PM »
Hi,

Can you post your script, please

May be there is another to do what you want with no change for retina...

Nicolas

Offline vsn3e8

  • Newbie
  • *
  • Posts: 6
Re: Retina Gesture.deltaPosition
« Reply #2 on: May 01, 2013, 09:27:54 PM »
float resolutionScale = (IsRetina()) ? 2 : 1;
PanCamera(deltaPosition * resolutionScale);


Offline Nicolas

  • Administrator
  • Hero Member
  • *****
  • Posts: 792
Re: Retina Gesture.deltaPosition
« Reply #3 on: May 01, 2013, 09:34:39 PM »
Hi,

I want what you do in the PanCamera method.

Nicolas

Offline vsn3e8

  • Newbie
  • *
  • Posts: 6
Re: Retina Gesture.deltaPosition
« Reply #4 on: May 01, 2013, 09:49:50 PM »
Camera.mainCamera.transform.position = Camera.mainCamera.transform.position + new Vector3(delta.x, delta.y, 0);


Offline Nicolas

  • Administrator
  • Hero Member
  • *****
  • Posts: 792
Re: Retina Gesture.deltaPosition
« Reply #5 on: May 01, 2013, 10:38:32 PM »
Ok, I'm understanding, but you use 2d Delta position to move camera in a 3D world ...

Do you want :
1- that camera follow your finger
2- that camera move on the same direction of your finger at a constant speed

Nicolas



Offline vsn3e8

  • Newbie
  • *
  • Posts: 6
Re: Retina Gesture.deltaPosition
« Reply #6 on: May 01, 2013, 11:30:18 PM »
sorry, i should have stated that my game is a 2D game (isometric to be exact)

so yes, the camera to move with the same speed as my finger.



Ok, I'm understanding, but you use 2d Delta position to move camera in a 3D world ...

Do you want :
1- that camera follow your finger
2- that camera move on the same direction of your finger at a constant speed

Nicolas

Offline vsn3e8

  • Newbie
  • *
  • Posts: 6
Re: Retina Gesture.deltaPosition
« Reply #7 on: May 01, 2013, 11:33:32 PM »
I'm starting to think that perhaps the solution is to change my initial orthographic camera size so a zoom factor of 1, responds to pixel perfect panning.

In other words, easytouch delta position is doing exactly what it should be doing, and  I should be changing my camera orthographic size  to accommodate my request.

Thanks for your quick support.
« Last Edit: May 01, 2013, 11:42:51 PM by vsn3e8 »

Offline Nicolas

  • Administrator
  • Hero Member
  • *****
  • Posts: 792
Re: Retina Gesture.deltaPosition
« Reply #8 on: May 01, 2013, 11:51:45 PM »
IPAD2 = 1024 x 768
Retina = 2048 X 1536
So, of you course is you base you position on the delta position, it won't be correct, It will be more slower on retina

You have 1 solutions:
1- Base your position to NormalizedPosition (the value always in range 0 to 1) (this option is coming with EasyTouch 3)
but you can do it yourself like this :
   
Code: [Select]
Vector2 normalPosition = new Vector2(100f/Screen.width*gesture.position.x/100f,100f/Screen.height*gesture.position.y/100f);   
   
You can do the same thing with the delta position

Nicolas



« Last Edit: May 02, 2013, 12:11:19 AM by Nicolas »