lvjincheng 4 years ago
parent
commit
704a4598b2

+ 33 - 13
Assets/BowArrow/Scripts/Bluetooth/BluetoothAim.cs

@@ -359,22 +359,40 @@ class AimHandler
     {
         if (hasAutoIdentity)
         {
-            controlObj.transform.localRotation = Quaternion.Lerp(controlObj.transform.localRotation, newRotation, Time.deltaTime * 6);
+            // controlObj.transform.localRotation = Quaternion.Lerp(controlObj.transform.localRotation, newRotation, Time.deltaTime * 6);
+            newEularAngles.x = baseEularAngles.x + newRotation.eulerAngles.x;
+            newEularAngles.y = baseEularAngles.y + newRotation.eulerAngles.y;
+            newEularAngles.z = baseEularAngles.z + newRotation.eulerAngles.z;
+            controlObj.transform.localRotation = Quaternion.Lerp(
+                controlObj.transform.localRotation, 
+                Quaternion.Euler(newEularAngles.x, newEularAngles.y, newEularAngles.z), 
+                Time.deltaTime * 8
+            );
+            // controlObj.localEulerAngles = Vector3.Lerp(controlObj.localEulerAngles, newEularAngles, Time.deltaTime * 6);
         }
         if (doIdentity)
         {
-            if (Quaternion.Angle(newRotation, baseRotation) < 2) 
-            {
-                if (!hasAutoIdentity)
-                {
-                    controlObj.transform.localRotation = newRotation;
-                }
-                doIdentity = false;
-                hasAutoIdentity = true;
-            } else {
-                AccIdentity = AccOld;
-                MagIdentity = MagOld;
-            }
+            // if (Quaternion.Angle(newRotation, baseRotation) < 2) 
+            // {
+            //     if (!hasAutoIdentity)
+            //     {
+            //         controlObj.transform.localRotation = newRotation;
+            //     }
+            //     doIdentity = false;
+            //     hasAutoIdentity = true;
+            // } else {
+            //     AccIdentity = AccOld;
+            //     MagIdentity = MagOld;
+            // }
+            baseEularAngles.x = 0 - newRotation.eulerAngles.x;
+            baseEularAngles.y = 0 - newRotation.eulerAngles.y;
+            baseEularAngles.z = 0 - newRotation.eulerAngles.z;
+            newEularAngles.x = baseEularAngles.x + newRotation.eulerAngles.x;
+            newEularAngles.y = baseEularAngles.y + newRotation.eulerAngles.y;
+            newEularAngles.z = baseEularAngles.z + newRotation.eulerAngles.z;
+            controlObj.localEulerAngles = newEularAngles;
+            doIdentity = false;
+            hasAutoIdentity = true;
         }
     }
 
@@ -383,4 +401,6 @@ class AimHandler
     bool hasAutoIdentity = false;
     Quaternion newRotation;
     Quaternion baseRotation = new Quaternion(0, 0, 0, 1);
+    Vector3 baseEularAngles = new Vector3();
+    Vector3 newEularAngles = new Vector3();
 }

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

@@ -122,17 +122,17 @@ public class ShootCheck : MonoBehaviour
             {
                 gravity = Mathf.Clamp(rangeAcc, -0.981f, 0.981f);
             } 
-            if (acc - gravity > 2.4)
+            if (acc - gravity > 3)
             {
-                for (int i = 1; i < dataCount && i < 15; i++)
-                {
-                    if (accList[i] - gravity < - 1)
-                    {
-                        Dolock();
-                        Invoke("Unlock", 0.2f);
-                        return false;
-                    }
-                }
+                // for (int i = 1; i < dataCount && i < 15; i++)
+                // {
+                //     if (accList[i] - gravity < - 1)
+                //     {
+                //         Dolock();
+                //         Invoke("Unlock", 0.2f);
+                //         return false;
+                //     }
+                // }
                 hasReachShootThreshold = true;
                 maxAcc = acc;
             }