Ejemplo n.º 1
0
        /// <summary>
        /// Framerate-independent interpolation for position and Rotation
        /// </summary>
        /// <param name="sms"></param>
        /// <param name="scs"></param>
        /// <param name="smr"></param>
        /// <param name="deltaTime"></param>
        public static void Interpolate(SimulatorMovementSpeed sms, SimulatorMovementRotation smr, ref SimulatorCameraState scs, float deltaTime)
        {
            // Calculate the lerp amount, such that we get 99% of the way to our target in the specified time
            var positionLerpPct = 1f - Mathf.Exp(Mathf.Log(1f - 0.99f) / sms.PositionLerpTime * deltaTime);
            var rotationLerpPct = 1f - Mathf.Exp(Mathf.Log(1f - 0.99f) / smr.RotationLerpTime * deltaTime);

            scs.InterpolatingCameraState.LerpTowards(scs.TargetCameraState, positionLerpPct, rotationLerpPct);
            scs.InterpolatingCameraState.UpdateTransform(VRSF_Components.CameraRig.transform);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Evaluate the camera translation based on WASD and apply boost.
        /// </summary>
        /// <param name="sms"></param>
        /// <param name="deltaTime"></param>
        /// <returns>return true if translation is not a vector3.zero</returns>
        private bool EvaluateTranslation(SimulatorMovementSpeed sms, ref SimulatorCameraState scs, float deltaTime)
        {
            var translation = GetInputTranslationDirection() * sms.BaseSpeed * deltaTime;

            if (translation != Vector3.zero)
            {
                SimulatorCameraStateSystem.ResetCameraStateTransform(scs);

                // Speed up movement when shift key held
                if (Input.GetKey(KeyCode.LeftShift))
                {
                    // Modify movement by a boost factor (defined in Inspector and modified in play mode through up and down arrow)
                    translation *= Mathf.Pow(2.0f, sms.LeftShiftBoost);
                }

                scs.TargetCameraState.Translate(translation);
                return(true);
            }
            return(false);
        }