I don’t know how the sliding in super mario 64 works but assuming you just slide in the steepest direction with reduced control you could also use the following if you don’t want to use physics for this/want more control:
You can get the slope where your character is standing. For example with a line trace below your character → gives you surface normal → calculate dot product with (0, 0, 1) to determine how steep the ground is. You can then also take the normal and zero-out the Z-component of it and renormalize it to get the direction of steepest downward slope (this is not 100% perfect as it might push your character in the air a little bit but gravity should solve this if you dont wanna slide too fast, else you can recalculate the correct Z component for the sliding direction instead of zeroing it but that’s a bit more math and this answer is already pretty long). Then if the slope you calculate with the dot product passes a certain “sliding threshold” you can just apply a constant force/velocity (maybe based on slope?) in that downward direction (also make sure to recalculate the above constantly while sliding so the direction and speed get adjusted if the ground changes).
To limit the player’s movement abilities you can play around with settings like “Rotation Rate”, “Braking Deceration” and “Ground Friction” in the movement component of you character and apply those values when sliding.
2 Likes