void Update() { isGrounded = playerJump.getGrounded(); isGroundedUp = Physics2D.OverlapCircle(groundCheckUp.position, groundRadius, groundLayer); //Debug.Log("Get Button => "+ Input.GetButton("Crouch")); //Debug.Log("GroundedUp => "+!isGroundedUp); //Debug.Log("isGrounded => " + isGrounded); //Debug.Log("velo => "+GetComponent<Rigidbody2D>().velocity.y); if (Input.GetButtonDown("Crouch") && !isGroundedUp && isGrounded && GetComponent <Rigidbody2D>().velocity.y == 0) { isCrouched = !isCrouched; playerRun.canRun = !isCrouched; anim.SetBool("Crouched", isCrouched); } }
void Update() { if (applyCustomGravity) { if (GetComponent <Rigidbody2D>().velocity.y < 0 && !playerJump.getGrounded()) { GetComponent <Rigidbody2D>().velocity += Vector2.up * Physics2D.gravity.y * (fallMultiplier - 1) * Time.deltaTime; } else if (GetComponent <Rigidbody2D>().velocity.y > 0 && !Input.GetButton("Jump")) { //Debug.Log("Player Jump with lowJumpMultiplier!"); //Debug.Log("Velocity => "+ Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime); GetComponent <Rigidbody2D>().velocity += Vector2.up * Physics2D.gravity.y * (lowJumpMultiplier - 1) * Time.deltaTime; } } }