public void JumpPressed()
    {
        bool jumpIsWithinLeniencyWindow = !isGrounded && airTime <= jumpLeniencyTime;

        if (Dashing)
        {
            return;
        }

        if (isGrounded || jumpIsWithinLeniencyWindow)
        {
            jumping    = true;
            velocity.y = jumpPower;
            sounds.PlayJumpSound();

            if (jumpIsWithinLeniencyWindow)
            {
                print("Saved by the leniency");
            }
        }

        else if (!IsGrounded)
        {
            StartGlide();
        }
    }
示例#2
0
    //****************************************************************** Update function ******************************************************************

    // Update is called once per frame
    void Update()
    {
        horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
        characterAnimator.Animate(controller.getGrounded(), horizontalMove);
        controller.Move(horizontalMove * Time.fixedDeltaTime, false /*, jump*/);

        /*if (Input.GetButtonDown("Jump"))
         * {
         *  jump = true;
         * }*/

        if ((Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Keypad1)) && !isAttacking) //Unity has their own stuff for mouse buttons too, might be good for eventual control customization
        {
            //Sets the attacking bool true, locking into a single attack at a time and preventing other animations
            isAttacking = true;

            //Calls DoAttack, which will set the hitbox collider active for a duration of time
            StartCoroutine(DoAttack());

            characterAnimator.PlayMeleeAnimation();

            soundManager.PlayJumpSound();
        }
    }