Pinch zoom

Hello, I am making upgrade of pinch zoom, which will on camera size increasing move camera higher, and on camera size decreasing move camera lower… I tried to do this upgrade but when is display touched by two fingers, the position of camera go automatically higher and ignores any gestures. Please, help me. :slight_smile:

void Update()
	{
		// If there are two touches on the device...
		if (Input.touchCount == 2) {
			// Store both touches.
			Touch touchZero = Input.GetTouch (0);
			Touch touchOne = Input.GetTouch (1);
		
			// Find the position in the previous frame of each touch.
			Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition;
			Vector2 touchOnePrevPos = touchOne.position - touchOne.deltaPosition;

			// Find the magnitude of the vector between the touches in each frame.
			float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude;
			float touchDeltaMag = (touchZero.position - touchOne.position).magnitude;

			// Find the difference in the distances between each frame.
			float deltaMagnitudeDiff = prevTouchDeltaMag - touchDeltaMag;

            //===========================================================>>
			transform.Translate (new Vector2(0,prevTouchDeltaMag) *moveSpeed);
           //<<===========================================================

			// If the camera is orthographic...
			if (GetComponent<Camera>().orthographic) {
				// ... change the orthographic size based on the change in distance between the touches.
				GetComponent<Camera>().orthographicSize += deltaMagnitudeDiff * orthoZoomSpeed;

				// Make sure the orthographic size never drops below zero.
				GetComponent<Camera>().orthographicSize = Mathf.Max (GetComponent<Camera>().orthographicSize, 0.1f);
		}
	}

Watch this video and you will get what you need.