I am using Unity to create a game, and using an android phone as a controller. The phone is functionaning as a websocket server that the unity app is connecting to and listening for the gyroscope sensor.
The problem is that if the unity app runs at lower fps it sees the phone rotate more, and at higher fps the phone rotates less.
This is where I am translating the data coming in and applying it to a capsule:
while (_ws.State == WebSocketState.Open)
{
...
//Data comes in as rad/sec, and I want it to be degrees/sec
float _radiansToDegrees = Time.deltaTime * Mathf.Rad2Deg;
var gyroRotation = new Vector3(g.values[0], g.values[1], g.values[2]) * _radiansToDegrees;
//I only care to rotate along x-axis
_capsule.Rotate(_uiController.IsPhoneAxis() ? new Vector3(gyroRotation.z, 0, 0) : new Vector3(-gyroRotation.x, 0, 0));
...
}
I had assumed using Time.deltaTime when converting radians to degrees would have made the incoming data not reliant on the games fps.
If I make the websockets sampling rate similar to the unity apps fps I get the expected rotation, however I need to prevent the fps from impacting my rotation.
After reading my own question I realized that the Time.deltaTime was the incorrect multiplier. I needed to multiply by my sampling rate.