Пример #1
0
    private void SetDeviceRotation()
    {
        if (!calibrating)
        {
            calibrating           = true;
            calibrationPercent    = 0f;
            prevScreenOrientation = (Input.gyro.attitude * xAxisOnly).eulerAngles.x;
        }
        calibrationPercent += Time.deltaTime;
        float xAngle = (Input.gyro.attitude * xAxisOnly).eulerAngles.x;
        float calibrationProgress = Ease.EaseInOutCirc(calibrationPercent);
        float newAngle            = Mathf.Lerp(
            prevScreenOrientation,
            xAngle,
            calibrationProgress);

        Vector2 pos = new Vector2(Input.gyro.gravity.x, xAngle) * 20f;

        // Lerp scale x
        // Lerp scale y of bubble independently
        gyroOffset =
            Quaternion.Euler(-newAngle, 0f, 0f);

        // press screen
        //
        // Lerp from currentRotation to prevRotation, 1f - time.deltaTime * calibrationSpeed
    }