Exemple #1
0
        public void SetTilt(Vector3 lookAtPosition, bool isInstant)
        {
            if (KickStarter.settingsManager.movementMethod == MovementMethod.UltimateFPS)
            {
                fpCam = UltimateFPSIntegration.GetFPCamTransform();
            }

            if (fpCam == null)
            {
                return;
            }

            if (isInstant)
            {
                isTilting = false;

                transform.LookAt(lookAtPosition);
                float tilt = transform.localEulerAngles.x;
                if (targetTilt > 180)
                {
                    targetTilt = targetTilt - 360;
                }

                if (fpCam && fpCam.GetComponent <FirstPersonCamera>())
                {
                    fpCam.GetComponent <FirstPersonCamera>().SetRotationY(tilt);
                }
                else if (KickStarter.settingsManager.movementMethod == MovementMethod.UltimateFPS)
                {
                    UltimateFPSIntegration.SetTilt(tilt);
                }
            }
            else
            {
                // Base the speed of tilt change on how much horizontal rotation is needed

                actualTilt = fpCam.eulerAngles.x;
                if (actualTilt > 180)
                {
                    actualTilt = actualTilt - 360;
                }

                Quaternion oldRotation = fpCam.rotation;
                fpCam.transform.LookAt(lookAtPosition);
                targetTilt     = fpCam.localEulerAngles.x;
                fpCam.rotation = oldRotation;
                if (targetTilt > 180)
                {
                    targetTilt = targetTilt - 360;
                }

                Vector3 flatLookVector = lookAtPosition - transform.position;
                flatLookVector.y = 0f;

                tiltSpeed     = Mathf.Abs(2f / Vector3.Dot(fpCam.forward.normalized, flatLookVector.normalized)) * turnSpeed / 100f;
                tiltSpeed     = Mathf.Min(tiltSpeed, 2f);
                tiltStartTime = Time.time;
                isTilting     = true;
            }
        }
Exemple #2
0
 private void UpdateTilt()
 {
     if (fpCam && fpCam.GetComponent <FirstPersonCamera>())
     {
         fpCam.GetComponent <FirstPersonCamera>().SetRotationY(actualTilt);
     }
     else if (KickStarter.settingsManager.movementMethod == MovementMethod.UltimateFPS)
     {
         UltimateFPSIntegration.SetTilt(actualTilt);
     }
 }