- Home /
camera smooth stop (continuously sliding), on touch end
Hello everybody, I'm trying to make camera like in Bad Piggies, when you previewing whole scene, you can drag your camera with one tap, and on TouchPhase.Ended it sliding continuously till it stops.
In my case X and Y, are calculated like: X = touch_v3_begin.x - touch.position.x.
I'm also thinking that on my TouchPhase.Moved is working not too smoothly..
switch ( touch.phase )
{
case TouchPhase.Began:
if (!beginshooting)
{
isSwipe = true;
bulletCamFollow = false;
touch_v3_begin = Camera.main.ScreenToWorldPoint(touch.position);
}
break;
case TouchPhase.Moved:
if (isSwipe)
{
isSwiping = true;
newpos = camera.transform.position-Vector3(X,Y, 0);
newpos.z = -10;
camera.transform.position = newpos;
}
break;
case TouchPhase.Ended:
if (isSwipe)
{
isSwipe = false;
isSwiping = false;
var distance : float = Vector3.Distance(camera.transform.position, newpos);
SlowDown(distance);
}
break;
}
}
Comment
Your answer
Follow this Question
Related Questions
Camera not moving 'smoothly' on drag. 2 Answers
First Person Camera is extremely jerky 4 Answers
How to make camera position relative to a specific target. 1 Answer
How to smooth the accelerometer data values 4 Answers
2D Camera (Android, Iphone) 1 Answer