void Awake() { if (SystemInfo.supportsGyroscope) { filter = new ComplementaryFilter(.98f, PREDICTION_TIME); Input.gyro.enabled = true; } else { filter = new ComplementaryFilter(.5f, PREDICTION_TIME); } posePredictor = new PosePredictor(PREDICTION_TIME); filterToWorldQ = Quaternion.AngleAxis(-Mathf.PI / 2, new Vector3(1, 0, 0)); originalPoseAdjustQ = Quaternion.AngleAxis(-windowOrientation * Mathf.PI / 18, new Vector3(0, 0, 1)); SetScreenTransform(); if (isLandscape) { filterToWorldQ *= inverseWorldToScreenQ; } Recenter(); }
void Awake() { if (instance != null) { UnityEngine.Debug.LogError("More than an instance of SensorFusion detected!"); } instance = this; if (SystemInfo.supportsGyroscope) { filter = new ComplementaryFilter(.98f); Input.gyro.enabled = true; Input.gyro.updateInterval = 0.0167f; // Set the update interval to it's highest value (60 Hz) } else { Debug.LogWarning("This device doesn't have a gyroscope! Using accelerometer only (if available)"); filter = new ComplementaryFilter(.5f); } posePredictor = new PosePredictor(); filterToWorldQ = Quaternion.AngleAxis((-Mathf.PI / 2) * Mathf.Rad2Deg, new Vector3(1, 0, 0)); originalPoseAdjustQ = Quaternion.AngleAxis((-windowOrientation * Mathf.PI / 18) * Mathf.Rad2Deg, new Vector3(0, 0, 1)); SetScreenTransform(); if (isLandscape) { filterToWorldQ *= inverseWorldToScreenQ; } Recenter(); }