Question by
kirtan09 · Mar 29, 2019 at 08:23 PM ·
androidtouchcamera-movementorthographic camera
Unity Touch Pan Orthographic camera,
I have written some code to pan in perspective view. I used that code and modified it to make it work in orthographic view. However, the display does not pan as expected. It just goes all over the place. Below is my code:
//Check if there is a touch detected.
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved)
{
Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
transform.Translate(-touchDeltaPosition.x * panSpeed, transform.position.y * panSpeed, 0);
//Set boundaries of how far the pan can go.
transform.position = new Vector3(
Mathf.Clamp(transform.position.x, -14f, -39f),
Mathf.Clamp(transform.position.y, 29f, 63f),
Mathf.Clamp(transform.position.z, -72f, 20f));
}
Comment