Sliding down a slope

How do you make a character slide down like in Super mario 64?
What parameters you have to change in your character?

I assume you’re asking only about physics and not animations. In that case for the slope you can change the walkable floor angle to something really low which should force the character to slide. Or the same property in the character movement component which you can set to a low value if some conditions are met.

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.

1 Like

i did not really understand. Do you have any screenshots?

Hey, I don’t have any screenshots right now but I can try to explain in more detail:
So what you’re looking for is the slope below your character to give you both the sliding direction and speed (based on slope steepness). For both we need the surface normal of the ground below the character and that we can aquire by using the line trace function starting from your character’s hips or so and tracing down below the feet. If you break/split the output result of the trace (right click on the blueprint output) there should be the “normal” vector. Now we could use the dot product to determine steepness but in this case just taking the z component of the normal will yield rhe exact same result.
If the result is 1, the normal points straight up. If it’s 0, the normal doesn’t point up at all and our slope is straight down. We don’t care for negative values here, so you should clamp the result between 0 and 1 and then invert it by subtracting that result from 1 (what was 1 will now be 0 and the previous 0 will be 1). This finally gives you the steepness → 1 means max steepness and 0 means flat ground. You can use this to check whether sliding ist possible (e.g. If the value ist higher than 0.2) and use is to scale your velocity so you slide down faster, the steeper the slope. Now we only need the direction to slide in. To aproximate it, you can simply imagine that you’re looking straight down on your scene at the surface normal. If the ground is flat, the normal points straight up at you but if there is a slope, it will tilt towards the downhill direction and thus if you just take just the x,y components of the normal, leaving z = 0, it will give you the downhill direction your character should move towards. But before you use it you should renormalize it and that’s basically it. The rest is just playing around with values in the movement component to for example limit player Input when sliding etc. but there should be tutorials for that.
Hope that helps :slight_smile:

1 Like