Przeglądaj źródła

地磁计校准bug

yichael 4 lat temu
rodzic
commit
a36e70412a

+ 12 - 9
Assets/BowArrow/Scripts/Bluetooth/BluetoothAim.cs

@@ -176,8 +176,8 @@ class AimHandler
     Vector3 Gyr = default;
     Vector3 Mag = default;
     o09Axis _9Axis = new o09Axis();
-
-
+    //是否校正地磁计
+    bool bAjustMagnetometer = false;
     //转换读取的数据,无符号->有符号
     float TwoByteToFloat(byte b1, byte b2) 
     {
@@ -223,9 +223,12 @@ class AimHandler
         if (MagCalibrationButton != null)
         {
             MagCalibrationButton.onClick.AddListener(delegate {
-                if (MagCalibrater.Calibration)
+
+                // if (MagCalibrater.Calibration)
+                if (bAjustMagnetometer)
                 {
-                    MagCalibrater.Calibration = false;
+                    // MagCalibrater.Calibration = false;
+                    bAjustMagnetometer = false;
                     MagCalibrationButton.GetComponentInChildren<Text>().text = "开始地磁计校准";
                     float[] dataFloats = new float[6];
                     dataFloats[0] = MagCalibrater.Center.x;
@@ -234,13 +237,12 @@ class AimHandler
                     dataFloats[3] = MagCalibrater.Radius.x;
                     dataFloats[4] = MagCalibrater.Radius.y;
                     dataFloats[5] = MagCalibrater.Radius.z;
-                    string dataStr = String.Join(",", dataFloats);
-                    PlayerPrefs.SetString("o0MagneticCalibrater", dataStr);
                 }
                 else
                 {
-                    MagCalibrater.Calibration = true;
-                    MagCalibrationButton.GetComponentInChildren<Text>().text = "停止地磁计校准";
+                    // MagCalibrater.Calibration = true;
+                    bAjustMagnetometer = true;
+                    MagCalibrationButton.GetComponentInChildren<Text>().text = "停止地磁计校准";    
                 }
             });
         }
@@ -367,7 +369,8 @@ class AimHandler
         }
         if (doIdentity)
         {
-            _9Axis.SetIdentityAccordingToRecords();
+            // _9Axis.SetIdentityAccordingToRecords();
+            _9Axis.SetIdentity();
             if (controlObj != null)
             {
                 controlObj.localRotation = Quaternion.identity;

+ 1 - 1
Assets/BowArrow/Scripts/Bluetooth/ShootCheck.cs

@@ -19,7 +19,7 @@ public class ShootCheck : MonoBehaviour
         ins = this;
         BluetoothDispatcher.shoot = OnDataReceived;
 
-         //socket
+        //socket
         string serverIP = "192.168.1.103";
         string address = "ws://" + serverIP + ":8088/Ble/";
         webSocket = new WebSocket(new Uri(address));

+ 1 - 1
Assets/BowArrow/Scripts/Game/ArmBow.cs

@@ -127,7 +127,7 @@ public class ArmBow : MonoBehaviour
         // Arrow.speed = BaseSpeedSlider.ins.getValue();
         // Arrow.speed = Mathf.Pow(ShootCheck.ins.shootSpeed, ShootCheck.ins.shootSpeed < 13 ? 2f: (ShootCheck.ins.shootSpeed < 15 ? 2.5f : 3.0f));
 
-        Arrow.speed = ShootCheck.ins.shootSpeed/16*90; 
+        Arrow.speed = ShootCheck.ins.shootSpeed/16*80; 
 
         arrowCopy.SetActive(true);  
         arrow.SetActive(false);