Explorar el Código

模拟鼠标优化

lvjincheng hace 4 años
padre
commit
3f5c780ebe

+ 5 - 4
Assets/BowArrow/Scripts/Bluetooth/AimHandler.cs

@@ -216,10 +216,9 @@ public class AimHandler : MonoBehaviour
                     if (SB_EventSystem.ins && SB_EventSystem.ins.simulateMouseIsAwaked) {
                         //鼠标居中
                         SB_EventSystem.ins.MakeMouseToScreenCenter(); 
-                    } else {
-                        //视角回正
-                        DoIdentity();
                     }
+                    //视角回正
+                    DoIdentity();
                 } else if (bytes[0] == 0x66 && bytes[1] == 0x32) {
                     if (SB_EventSystem.ins) {
                         //唤起/隐藏虚拟鼠标
@@ -367,6 +366,8 @@ public class AimHandler : MonoBehaviour
     public void DoIdentity()
     {
         _9Axis.SetIdentityAndSave();
-        if (controlObj) controlObj.localRotation = _9Axis.getLastState().Qua;
+        Quaternion qua = _9Axis.getLastState().Qua;
+        newRotation = qua;
+        if (controlObj) controlObj.localRotation = qua;
     }
 }

+ 3 - 2
Assets/BowArrow/Scripts/Expand/SB_EventSystem.cs

@@ -100,10 +100,10 @@ public class SB_EventSystem : MonoBehaviour
             if (!simulateMouseIsAwaked) return;
             if (hasAxisQuat) {
                 Vector3 lastAngle = nowAxisQuat.eulerAngles;
-                nowAxisQuat = Quaternion.Lerp(nowAxisQuat, targetAxisQuat, Time.deltaTime * 15f);
+                nowAxisQuat = Quaternion.Lerp(nowAxisQuat, targetAxisQuat, Time.deltaTime * 8f);
                 Vector3 curAngle = nowAxisQuat.eulerAngles;
                 float dx = FormatDeltaAngleY(curAngle.y - lastAngle.y) / 150f * simulateMouse.GetScaleScreenWidth();
-                float dy = -FormatDeltaAngleX(curAngle.x - lastAngle.x) / 150f * simulateMouse.GetScaleScreenHeight();
+                float dy = -FormatDeltaAngleX(curAngle.x - lastAngle.x) / 100f * simulateMouse.GetScaleScreenHeight();
                 deltaVectorForMouse.x = dx;
                 deltaVectorForMouse.y = dy;
                 simulateMouse.MoveMousePointer(deltaVectorForMouse);
@@ -140,6 +140,7 @@ public class SB_EventSystem : MonoBehaviour
 
     //鼠标居中
     public void MakeMouseToScreenCenter() {
+        hasAxisQuat = false;
         simulateMouse.MakeMouseToScreenCenter();
     }