I use this code to track the movement of the gyroscope and rotate the object:
Vector3 previousEulerAngles = transform.eulerAngles;
Vector3 gyroInput = -Input.gyro.rotationRateUnbiased;
Vector3 targetEulerAngles = previousEulerAngles + gyroInput * Time.deltaTime * Mathf.Rad2Deg;
targetEulerAngles.x = 0.0f;
targetEulerAngles.y = 0.0f;
transform.eulerAngles = targetEulerAngles;
Everything works smoothly and almost the way I need, but there are 2 problems. The first is that when the smartphone is sharply rotated and when it is rotated 360 degrees or more, the object begins to roll away from its initial position. A collapse effect appears.
The second problem is that if the device is rotated before starting the application, then the rotation of the object starts from the initial position, and not from the position of the gyroscope. I’ve spent a few days already solving these problems.
Maybe someone has already encountered such a problem?