Question by
LT23Live · Aug 10, 2016 at 07:34 PM ·
androidrotationquaterniongyroscope
Android - Gyroscope - When I hold still it, the camera continues to rotate
Hi, I have a gyro controlled camera for android devices. When I rotate it works perfectly, the only downside is when I stay still it tends to rotate on the y axis on its own.
public bool UseGyro;
public bool invertGyroX;
public bool invertGyroY;
public bool lockGyroX;
public bool lockGyroY;
public float rotateSpeed;
void Update ()
{
if (Input.gyro.enabled) {
float gyroX = 0;
float gyroY = 0;
float xRotValue = 1;
float yRotValue = 1;
if (invertGyroX) {
xRotValue = -1;
}
if (invertGyroY) {
yRotValue = -1;
}
if (!lockGyroX) {
gyroX = Input.gyro.rotationRateUnbiased.x * xRotValue;
}
if (!lockGyroY) {
gyroY = Input.gyro.rotationRateUnbiased.z * yRotValue;
}
transform.eulerAngles += new Vector3 (gyroX, gyroY, 0);
}
}
if Anyone has encountered this issue before please let me know!
Comment