Question by
JonathanPaulCarr · May 02, 2016 at 11:24 PM ·
androidfirst-person-controllergyroscope
Android gyro z-axis drift problem
I'm using the following code to as a script attached to my main camera. The script works except for slight z-axis drift when moving android device in circular motions. Devices are Samsung Note 5 phone and Nvidia Shield tablet. Can anyone point me in the right direction to remove this drift?
using UnityEngine;
using System.Collections;
public class GyroController : MonoBehaviour
{
void Start()
{
Input.gyro.enabled = true;
}
void Update()
{
transform.Rotate(-Input.gyro.rotationRateUnbiased.x, -Input.gyro.rotationRateUnbiased.y, 0f);
}
}
Any help would be greatly appreciated. Thanks,
Jonathan
Comment
I'm facing the same problem and haven't figured out a fix yet, when using transform.rotation = quaternion.euler it only rotates very slightly on the x/y axis and 0 on z. But if the x/y don't work then it's no point. Have you figured out a fix for this yet?