I have here a simplified version of my gyro-controlled camera with a sensitivity modification (a side effect of increasing sensitivity is that the jitteriness is exacerbated).
public class GyroControl : MonoBehaviour
{
private Transform _rawGyroRotation;
Vector3 gyroAdjust;
[SerializeField] private float _smoothing = 0.1f;
void Start()
{
Input.gyro.enabled = true;
Application.targetFrameRate = 60;
_rawGyroRotation = new GameObject("GyroRaw").transform;
_rawGyroRotation.position = transform.position;
_rawGyroRotation.rotation = transform.rotation;
}
private void Update()
{
_rawGyroRotation.rotation = Input.gyro.attitude;
gyroAdjust = _rawGyroRotation.rotation.eulerAngles * 2; //increase rotation sensitivity
transform.rotation = Quaternion.Euler(gyroAdjust);
transform.rotation = Quaternion.Slerp(transform.rotation, _rawGyroRotation.rotation, _smoothing);
}
}
When in motion, the jittering isn’t noticeable. But when you hold the phone still, there’s what I assume to be just analogue noise that causes jittering. I would really appreciate any help or advice on how to add a filter or something to reduce the jittering for this kind of controller.
Thanks.