I have this code which is rotating my camera object based on Gyro it is working fine
public void CalibrateYAngle()
{
calibrationYAngle = appliedGyroYAngle - initialYAngle; // Offsets the y angle in case it wasn't 0 at edit time.
}
void ApplyGyroRotation()
{
transform.rotation = Input.gyro.attitude; //
transform.Rotate(0f, 0f, 180f, Space.Self); // Swap "handedness" of quaternion from gyro.
transform.Rotate(90f, 180f, 0f, Space.World); // Rotate to make sense as a camera pointing out the back of your device.
appliedGyroYAngle = transform.eulerAngles.y; // Save the angle around y axis for use in calibration.
}
public void Update() {
ApplyGyroRotation();
ApplyCalibration();
}
but sometime my camera start to rotate slowly slowly automatically. It slowly rotate left or right but sometime not always. What I am doing wrong? due to inaccurate sensors values?
Input.compass
? \$\endgroup\$