# sync touch move with camara position

Member ✭✭

Hy,

I run into problems on a little mathematical problem.
The Camara hovers over a plane, looking down to it by 90°

I have to zoom the Plane setting the FOV (for some other reasons it is absolutely necessary)

Now the user should move the camera by his TouchMove to a new position x / y

depending on the FOV, the "map" is running faster / slower than the finger.

`````` private void HandleTouchMove(TouchMoveEventArgs args)
{
float scaler = 0.1f; //scaler is for slowing down the movement-speed, i looking to find a way depending on FOV
m_CameraNode.Position = new Vector3(m_CameraNode.Position.X - args.DX * scaler, m_CameraNode.Position.Y,
m_CameraNode.Position.Z + args.DY * scaler);
}
``````

Has anyone from you a solution, ore a formula to set the Position direct on the touch.
Do You think it is necessary to do on every step a Ray-cast, and set the camera to this position? Sounds like a Nuke for killing some bugs..

Im happy for every suggestion.

Greetings,
Roman

• USMember ✭✭

Hello

You can try this:

``````if (Input.NumTouches == 2) {
var state1 = Input.GetTouch(0);
var state2 = Input.GetTouch(1);

var distance1 = Distance(state1.Position, state2.Position);
var distance2 = Distance(state1.LastPosition, state2.LastPosition);
_cameraNode.Translate(new Vector3(0, 0, (distance1 - distance2) / 50.0f));
}

float Distance(IntVector2 v1, IntVector2 v2) {
return (float)Math.Sqrt((v1.X - v2.X) * (v1.X - v2.X) + (v1.Y - v2.Y) * (v1.Y - v2.Y));
}
``````

In case when setting the FOV is not necessary, you still can use Camera.Zoom (float) property instead of changing the Position, because it is relatively easy, just make sure to set some lower limit on Zoom value (0.1f is OK).