When I press left shift (crouching) my character falls through the ground, what ofc shouldn’t happen. I compared my script to other scripts on the internet but the code seems fine, so idk why it’s happening
Here’s the code: (I won’t paste everything because that would be too much)
private void MyInput()
{
horizontalInput = Input.GetAxisRaw("Horizontal");
verticalInput = Input.GetAxisRaw("Vertical");
if(Input.GetKey(jumpKey) && readyToJump && grounded)
{
readyToJump = false;
Jump();
Invoke(nameof(ResetJump), jumpCooldown);
}
if (Input.GetKeyDown(crouchKey))
{
transform.localScale = new Vector3(1f, crouchYScale, 1f);
rb.AddForce(Vector3.down * 1f, ForceMode.Impulse);
}
if (Input.GetKeyUp(crouchKey))
{
transform.localScale = new Vector3(1f, startYScale, 1f);
}
}
And here an image of how I set up the player:
Thanks in advance!