How would you go about adding sliding to movement?

I’ve got a bit of a problem with some of my movement script. I don’t actually need direct help with the code, but I need help with a logic problem.

Right now, the players can move around with WASD, standard FPS controls. Their speed is increased and decreased depending on whether or not they are moving up and down slopes, they can jump, and they have stamina. However, one part of this is giving me trouble: sliding down steep slopes.

My current approach is to take the normal direction of the surface the player last collided with from the bottom and check to see if the combined X and Z values are greater than a number. If they are, the player is marked as sliding and can’t control themselves until the normal of the surface they’re on is less than the previously used number.

However, this causes the player to slide down tiny bumps that they should be able to just step over if they were actually a walking human.

Is there (of course there is one, I’m just too dumb to figure it out apparently) a better way to do this? I’ve tried fiddling around with checking ahead of the player to see if the bump is small with raycasting, but every result I’ve gotten has been janky. If anybody can help, I’d really appreciate it, even if it’s just throwing out ideas for me to try.

I’d raycast around the player’s feet to see if the ground is close. In a 3D game, I’d use maybe 4 raycasts by the feet. Front Center, Left Foot, Right Foot, Back Center.

If only 1 raycast hits a slope and the other 3 show solid ground, then don’t slide.

If 1 raycast hits a slope, and the other raycasts hit a slope or hit nothing but air, then you know you’re half off a cliff and it might be time to slide.