Example #1
0
    private void SetMovementSpeed()
    {
        if (Input.GetKey(runKey) && Input.GetKey(KeyCode.W) && staminaBar.currentStamina >= 1f)
        {
            RunAnim(true);
            runSpeed = 10;
            staminaBar.DrainStamina(drainAmount);
            movementSpeed = Mathf.Lerp(movementSpeed, runSpeed, Time.deltaTime * runBuildUpSpeed);
        }

        else if (Input.GetKey(KeyCode.S))
        {
            runSpeed      = 2;
            movementSpeed = Mathf.Lerp(movementSpeed, runSpeed, Time.deltaTime * runBuildUpSpeed);
        }

        else
        {
            RunAnim(false);
            movementSpeed = Mathf.Lerp(movementSpeed, walkSpeed, Time.deltaTime * runBuildUpSpeed);
        }
    }