Exemplo n.º 1
0
            private static float calculateSmoothSnapAngle(float mouseX)
            {
                float dt = Time.deltaTime;

                currentDt += dt;
                if (currentDt < SMOOTH_SNAP_INCREMENT_TIME_DELTA)
                {
                    return(0f);
                }
                else
                {
                    // We've hit our deltaT target, so reset it and continue
                    // with calculating the next increment.
                    currentDt = 0f;
                }
                float finalSnapTarget     = VHVRConfig.GetSnapTurnAngle() * smoothSnapDirection;
                float smoothSnapIncrement = VHVRConfig.SmoothSnapSpeed() * smoothSnapDirection;

                if (Mathf.Abs(finalSnapTarget) > Mathf.Abs(currentSmoothSnapAmount + smoothSnapIncrement))
                {
                    // We can still increment by the full "smoothSnapIncrement" and
                    // be below our final target.
                    return(smoothSnapIncrement);
                }
                else
                {
                    // If we increment by the full amount, we'll exceed our target, so
                    // we should only return the difference
                    return((Mathf.Abs(finalSnapTarget) - Mathf.Abs(currentSmoothSnapAmount)) * smoothSnapDirection);
                }
            }