How do you reduce jittering for gyroscope control system?
This is 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. The controller is based off a controller I got from here: https://gist.github.com/kormyen/a1e3c144a30fc26393f14f09989f03e1 . That controller I linked doesn't have a multiplied by 2 Euler like I do (increases sensitivity ) but the jittering is still present in that version just not as bad.
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.
Your answer
Follow this Question
Related Questions
Mesh colliders stop working after exporting to iOS device. 0 Answers
Gyroscope controller jittering when holding phone still 1 Answer
Unity C# Android Gyro - Wrong Orientation 2 Answers
Im trying to make a player move 360 degree gyroscopic movement on my phone 0 Answers
Unexpected Symbol 'break' 2 Answers