Collisions with sliding/crouching

I’m making a crouching/sliding system and wondering how people deal with collisions due to the change in height
one solution would be to change the hipheight which can be reasonable for sliding but for crouching the collisions prevent you from going up-stair like terrain. I could change hipheight only for sliding but I want crouching to allow someone to go through small spaces, plus changing hipheight drastically makes the character all bouncy.

another solution i thought of would be welding a part below the humanoidrootpart and when sliding/crouching is initiated, humanoidrootpart’s collision would be turned off for that duration, but I think it’d be even worse for climbing up stairs.

my last solution is a raycast shooting out from both humanoidrootpart and the weld and if it hit’s something then change the cancollide for the other piece but that is a tacky solution and i don’t like it, haven’t tried it though so idk how it would fair with stairs.

Are you sure the animations don’t alter the collisions themselves?

1 Like

I don’t believe so, it looks like it collides the same when crouching or sliding (without change in hipheight)

you could always just have only one raycast active while sneaking like you said but instead, by default set the hip height a little higher, high enough so the player can walk up terrain, and if raycast then lower hip height. That or you store some type of attribute with the desired hip height for all objects that cause issues and raycast returns that attribute and sets the hip height to that, kinda scuffed but it would be cleaner and more flexible that having 2 different preset hip heights(if no hip height attribute found then return a base height ofc)

I think you’re right about using only the rootpart as a hitbox, but changing hipheight that frequently can make animation and the camera jittery. I thinking about just two raycasts; one at the top and bottom of the humanoidrootpart casting direction of the player’s it’s move direction, then I subtract the difference of distances, from there I’ll be able to determine if I should enable collision on the humanoidrootpart or not. I’ll try this out and see how it works

1 Like

Good idea too, you should keep in mind performance won’t be too much of an issue if you’re only connecting a run service loop while the player is sneaking. So don’t be afraid to use solutions like those as a temporary solution or even sometimes permanent

1 Like