unity陀螺仪只读取两个轴

Unity gyroscope reads only two axes

我想让陀螺仪只改变物体的 x 轴和 y 轴。有单轴和三轴的代码(主要是用),但是我找不到关于双轴的任何东西,我自己也做不出来。

在应用之前重置 z 轴或任何轴-

private Vector3 startEulerAngles;
private Vector3 startGyroAttitudeToEuler;

private void Start()
{
    Input.gyro.enabled = true;
    startEulerAngles = transform.eulerAngles;
    startGyroAttitudeToEuler = Input.gyro.attitude.eulerAngles;
}

private void Update()
{
    Vector3 deltaEulerAngles = Input.gyro.attitude.eulerAngles - startGyroAttitudeToEuler;

    // Z-axis reset, so it won't be applied. 
    deltaEulerAngles.z = 0.0f;

    transform.eulerAngles = startEulerAngles - deltaEulerAngles;
}