void LateUpdate() { if (Input.touchCount >= 3) { // Don't do anything :) This is here as a stub, and to block operation if too many touches } if (Input.touchCount == 2) { // TWO-FINGER TOUCH CONTROLS // PINCH = Zoom in and out, as mousewheel // TWIST = Rotate entire camera assembly around the base (in the Y axis) // VERTICAL SWEEP = Rotate camera pitch up and down // // All of these functions can happen at once, using a helper function that needs to be in // Standard Assets: 'TouchHandler' float pinchAmount = 0; Quaternion desiredRotation = transform.rotation; // Run the TouchHandler TouchHandler.Calculate(); // get pitch sweep distance float rotX = TouchHandler.sweepDistanceDelta; // clamp it so it doesn't go too fast Mathf.Clamp(rotX, -.05f, .05f); if ((CamFocus.transform.localEulerAngles.x >= PitchMax)) { rotX = -1f; } if ((CamFocus.transform.localEulerAngles.x <= PitchMin)) { rotX = 1f; } // apply it CamFocus.transform.Rotate(new Vector3(rotX, 0f, 0f), Space.Self); // zoom if (Mathf.Abs(TouchHandler.pinchDistanceDelta) > 0) { pinchAmount = TouchHandler.pinchDistanceDelta * .5f; } //rotate if (Mathf.Abs(TouchHandler.turnAngleDelta) > 0) { Vector3 rotationDeg = Vector3.zero; rotationDeg.z = -TouchHandler.turnAngleDelta * .5f; desiredRotation *= Quaternion.Euler(rotationDeg); } // apply pitch gameObject.transform.root.transform.Rotate(0f, TouchHandler.turnAngleDelta, 0f); // clamp zoom float temp = transform.localPosition.z; temp += pinchAmount; if (temp < -ZoomMax) { temp = -ZoomMax; } if (temp > -ZoomMin) { temp = -ZoomMin; } transform.localPosition = new Vector3(0f, 0f, temp); } }