|
|
@@ -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();
|
|
|
}
|