made a character that crouch, and altered it’s collider in code so it can go under small areas, it works fine but if uncrouch while being under a small area the character clips through the ground for some reaso, is there a fix to that?
thank you.
the crouching script:
void OnCrouch(InputValue value)
{
crouchInput = value.isPressed;
}
void Crouching()
{
if(crouchInput)
{
myAnimator.SetBool("isCrouching", true);
myRigidbody.velocity = new Vector2 (myRigidbody.velocity.x*0.6f, myRigidbody.velocity.y);
bodyCollider.size = new Vector2 (bodyCollider.size.x, 0.9145353f);
bodyCollider.offset = new Vector2 (bodyCollider.offset.x,-0.0611621f);
}
else
{
myAnimator.SetBool("isCrouching", false);
bodyCollider.size = new Vector2 (bodyCollider.size.x, 1.158416f);
bodyCollider.offset = new Vector2 (bodyCollider.offset.x,0.06077838f);
}
}
these are the colliders dimensions