Prevent physics-based character from flying into the air from slopes

I’m currently working on a custom, non-humanoid character that is controlled via the new mover constraints. I’ve found an issue where the character can “ramp” off of slopes to get airtime, but i’d like to avoid this if possible.

I’ve tried creating a linear velocity with an arbitrary negative Y-axis force and it mostly fixed the issue, but I still occasionally get jumps here and there if i hit a slope hard enough. I’ve also tried “anchoring” the character to the floor via recasts, but this causes replication issues as the character is controlled from the client.

Are there any physics-based solutions that would prevent this from occurring? Or better yet, is there a formula to determine how much downward force to apply to an assembly (based on mass or something) to prevent it from going airborne?

The arbitrary Y-axis force (which i’ll refer to as gravity) can’t instantly reduce the vertical velocity and make it go downward. I’m assuming you don’t want the character to go up after it “jumps” from a slope, and would rather have it go down immediately.

When your character goes up the slope, it has vertical velocity, which it most likely got from either the vertical components of the forces applied by your mover constraints or the normal force of the ramp. Your character will “ramp” off the slope and get airtime, if it still has some of that vertical velocity.

To fix this, you could connect a function to RunService.PreSimulation that:

  • checks which parts the character is touching, if it’s not touching the ground or a slope, then it is in free fall

  • If it is in free fall, check to see if the assembly’s vertical velocity is positive

  • If it is positive, then this is most likely the instant after it has ramped off a slope, set the vertical velocity to zero

There’s no sure way to tell, how much time has passed since it left the ramp, so it may go up a teeny-tiny bit in that small instant, once the vertical velocity is set to zero, gravity will do the rest of the work.