void Rotate()
{
Vector3 lastDirectionInGlobal = _camera.ScreenPointToRay(rightFingerLastPoint).direction;
Vector3 currentDirectionInGlobal = _camera.ScreenPointToRay(rightFingerCurrentPoint).direction;
Quaternion rotation = Quaternion.identity;
rotation.SetFromToRotation(lastDirectionInGlobal, currentDirectionInGlobal);
ownTransform.rotation = ownTransform.rotation * Quaternion.Euler(0, kInverse ? rotation.eulerAngles.y : -rotation.eulerAngles.y, 0);
rotation.SetFromToRotation( cameraTransform.InverseTransformDirection(lastDirectionInGlobal),
cameraTransform.InverseTransformDirection(currentDirectionInGlobal));
cameraTransform.localRotation = Quaternion.Euler(kInverse ? rotation.eulerAngles.x : -rotation.eulerAngles.x, 0, 0) * cameraTransform.localRotation;
rotation = Quaternion.Euler(Mathf.Clamp (rotation.eulerAngles.x, -80, 80),Mathf.Clamp (rotation.eulerAngles.y, -80, 80), 0);//using mathclamp for rotation limit on x & y
rightFingerLastPoint = rightFingerCurrentPoint;
rotation = Quaternion.Euler(cameraTransform.rotation.eulerAngles.x, cameraTransform.rotation.eulerAngles.y, 0);
cameraTransform.rotation = rotation;
}
I have done clamping for x axis (-80,80) degree which is working fine, but y axis showing no clamping on (-80,80) degree . Am i doing something wrong. please help me.