How to change box collider size without falling through the ground

I have to make a crouch animation, so i need to change the size of the collider to allow the character pass through small holes, but when I change the height the charachter fall through the ground, any help?

I’m going to assume the change in size is instant and you don’t have the size change slowly over time. You need to change the position as well as height when your character crouches otherwise the collider’s bounds might go through the ground. You could change the character’s Y position based on the new crouched height and the character’s height before he crouched. A similar approach could be used when standing up.