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));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.