Selaa lähdekoodia

射击识别方法更换

lvjincheng 4 vuotta sitten
vanhempi
sitoutus
d86a91575b
1 muutettua tiedostoa jossa 7 lisäystä ja 6 poistoa
  1. 7 6
      Assets/BowArrow/Scripts/Bluetooth/ShootCheck.cs

+ 7 - 6
Assets/BowArrow/Scripts/Bluetooth/ShootCheck.cs

@@ -112,8 +112,8 @@ public class ShootCheck : MonoBehaviour
         ArmBow.ins.shootBackTime=int.Parse(ArmBowInputField.text);
     }
     public void OnBluetoothReady(BluetoothShoot bluetoothShoot) {
-        // bluetoothShoot.WriteData(JsonUtility.ToJson(cmd).Replace("\"", ""));
-        bluetoothShoot.WriteData("T");
+        bluetoothShoot.WriteData(JsonUtility.ToJson(cmd).Replace("\"", ""));
+        // bluetoothShoot.WriteData("T");
     }
 
     public void OnDataReceived(byte[] bytes) {
@@ -190,7 +190,7 @@ public class ShootCheck : MonoBehaviour
             shootSpeed = 0;
             float lasKeytAcc = 0;
             int keyAccIndex = 0;
-            float timeInterval = 0.01f;
+            float timeInterval = 0.002f;
             foreach (var keyAcc in keyAccList)
             {
                 if (keyAccIndex > 0)
@@ -208,11 +208,12 @@ public class ShootCheck : MonoBehaviour
             //加速度acc的单位是g,最后需要乘上
             shootSpeed *= 9.80665f;
             //积分出来的值还是太小,需要一个倍率
-            shootSpeed *= 30;
-            Debug.LogWarning("初速度: " + shootSpeed + " 帧数: " + keyAccList.Count);
+            shootSpeed *= 20;
+            string strShootSpeed = "初速度: " + shootSpeed + " 帧数: " + keyAccList.Count + "\n";
+            Debug.LogWarning(strShootSpeed);
             
             
-            string str1 = "检测到射出的数据:\n";
+            string str1 = strShootSpeed + "检测到射出的数据:\n";
             for (int i=0;i<keyAccList.Count;i++)
             {
                 float keyAcc = keyAccList.ElementAt(i);