FOVKick.FOVKickDown C# (CSharp) Method

FOVKickDown() public method

public FOVKickDown ( ) : IEnumerator
return IEnumerator
    public IEnumerator FOVKickDown()
    {
        float t = Mathf.Abs((Camera.fieldOfView - originalFov) / FOVIncrease);
        while (t > 0)
        {
            Camera.fieldOfView = originalFov + (IncreaseCurve.Evaluate(t) * FOVIncrease);
            t -= Time.deltaTime;
            yield return new WaitForEndOfFrame();
        }

        Camera.fieldOfView = originalFov;
    }

Usage Example

Beispiel #1
0
        private void GetInput(out float speed)
        {
            // Read input
            float horizontal = CrossPlatformInputManager.GetAxisRaw("Horizontal"); //AMCLEAN changed GetAxis to GetAxisRaw
            float vertical   = CrossPlatformInputManager.GetAxisRaw("Vertical");   //AMCLEAN changed GetAxis to GetAxisRaw

            bool waswalking = _isWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            _isWalking = !Input.GetKey(KeyCode.LeftShift);
#endif
            // set the desired speed to be walking or running
            //speed = _isWalking ? walkSpeed : runSpeed;
            speed  = PlayerPrefs.GetFloat("MoveSpeed") * 10;
            _input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (_input.sqrMagnitude > 1)
            {
                _input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used

            if (_isWalking != waswalking && useFOVKick && _characterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!_isWalking ? _fovKick.FOVKickUp() : _fovKick.FOVKickDown());
            }
        }
All Usage Examples Of FOVKick::FOVKickDown