diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 934c9d2..d5cf6d6 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -62,9 +62,9 @@ public class GameManager : MonoBehaviour float pitch = Mathf.Atan2(-ax, Mathf.Sqrt(ay * ay + az * az)) * Mathf.Rad2Deg; // 俯仰角 // 积分得到角度变化 - angleX += gx * dt; // 绕X轴旋转 - angleY += gy * dt; // 绕Y轴旋转 - angleZ += gz * dt; // 绕Z轴旋转 + angleX = gx * dt; // 绕X轴旋转 + angleY = gy * dt; // 绕Y轴旋转 + angleZ = gz * dt; // 绕Z轴旋转 // 使用互补滤波来平滑姿态估计 // 这里的系数决定了加速度和陀螺仪的权重,通常设置为0.98