Walk up a ramp and your character slows to a crawl. Walk down it and the character bounces along in little hops, or slides when you let go of the keys. Unity player sliding on slopes is a classic movement bug, and it comes from only a few causes: friction settings, movement that ignores the surface angle, a slope limit that is too strict, or gravity fighting your velocity. This guide covers both Rigidbody and CharacterController movement with a fix for each symptom.
Why Slopes Cause Problems
Most movement code works in a flat world. It builds a direction from input, multiplies by speed and moves along the horizontal plane. On a slope, that direction points slightly into the ground or slightly off it. Going up, the ground pushes back, so you lose speed. Going down, the character walks off the surface, falls for a moment, lands, and repeats. That is the bouncing.
Gravity adds a second problem. A resting body on a slope has a gravity component pulling it downhill. With low friction it slides. With high friction it sticks to walls too, which is the opposite bug. The fix is to treat the slope explicitly rather than hoping one friction number works everywhere.
First decide which movement style you use. If you are not sure, the CharacterController vs Rigidbody guide explains the tradeoffs. The fixes below differ for each.
Rigidbody Sliding and Physics Materials
A Rigidbody character is moved by the physics engine, so friction matters. Friction comes from the colliders on both surfaces, using a Physics Material asset. It has these fields:
- Dynamic Friction: friction while sliding.
- Static Friction: friction needed to start sliding from rest.
- Bounciness: how much energy is kept on impact.
- Friction Combine and Bounce Combine: how the two surfaces’ values are merged (Average, Minimum, Multiply, Maximum).
Two common mistakes. First, the default material has friction 0.6, so a capsule with no material slides on steep ground but not on shallow ground. Second, if you assign a zero-friction material to the player so they don’t stick to walls, they will also slide down every slope. That is by design.
A practical split: keep the capsule at low friction (so it never snags on walls) and handle slope standing in code. Set Friction Combine to Minimum on the player material so the lowest value wins against any ground.
Project Movement Onto the Slope
Instead of moving along the flat plane, move along the ground surface. You need the ground normal, then Vector3.ProjectOnPlane flattens your desired direction onto it. A short raycast down from the feet gives the normal. The raycast tutorial explains layer masks and hit data if this is new.
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class SlopeMover : MonoBehaviour
{
[SerializeField] float speed = 6f;
[SerializeField] float groundCheckDistance = 0.3f;
[SerializeField] float maxSlopeAngle = 45f;
[SerializeField] LayerMask groundMask = ~0;
Rigidbody rb;
Vector3 input;
RaycastHit groundHit;
bool grounded;
void Awake() => rb = GetComponent<Rigidbody>();
void Update()
{
input = new Vector3(Input.GetAxisRaw("Horizontal"), 0f, Input.GetAxisRaw("Vertical")).normalized;
}
void FixedUpdate()
{
grounded = Physics.Raycast(transform.position, Vector3.down, out groundHit,
1f + groundCheckDistance, groundMask);
Vector3 move = transform.TransformDirection(input);
float angle = grounded ? Vector3.Angle(Vector3.up, groundHit.normal) : 0f;
bool onSlope = angle > 0.1f && angle < maxSlopeAngle;
if (onSlope)
move = Vector3.ProjectOnPlane(move, groundHit.normal).normalized;
Vector3 v = move * speed;
if (!onSlope) v.y = rb.linearVelocity.y; // keep gravity and jumps on flat ground
rb.linearVelocity = v;
// no gravity while standing on a walkable slope, so we don't slide
rb.useGravity = !onSlope;
}
}
This uses the old Input Manager for brevity; swap in your own input reading if you use the Input System package. The raycast starts at the transform position and assumes it sits at the capsule’s center with a half height of about 1. Change the 1f to match your own capsule. When the surface is tilted, the projected direction points up or down the slope at the same speed, so you no longer lose speed going up.
Stopping the Slide at Rest
The code above turns off useGravity while on a walkable slope. With gravity gone and input at zero, velocity is zero, so the player stays put. This is the cleanest fix and avoids tuning friction numbers. When the angle exceeds maxSlopeAngle, gravity comes back and the player slides off steep surfaces, which is usually what you want.
Turning gravity back on matters. If you leave it off after the player walks off a ledge, they will float. The code sets it every physics step from the current ground state, so it always recovers. Do not use this trick while jumping: skip the slope logic for a short window after a jump, or the player will stick to the ground and the jump will fail. The player falls through floor guide covers related ground-contact problems.
CharacterController Slopes
CharacterController does not use physics materials or friction at all. It has its own settings in the Inspector:
- Slope Limit: the steepest angle it can walk up. Default is 45 degrees. Anything steeper blocks movement.
- Step Offset: the highest step it can climb. It must be smaller than the controller’s height plus the radius.
- Skin Width: a small buffer around the capsule. Too small causes jitter, too big causes the character to float. About 10 percent of the radius is the usual advice.
- Min Move Distance: movement smaller than this is ignored. The default is 0.001.
If the character refuses to climb a ramp, raise Slope Limit or make the ramp shallower. Slope Limit only blocks upward walking; it does not make the character slide down. If you want a slide on steep ground, add it yourself. OnControllerColliderHit gives you the contact normal:
Vector3 slideVelocity;
void OnControllerColliderHit(ControllerColliderHit hit)
{
float angle = Vector3.Angle(Vector3.up, hit.normal);
if (angle > controller.slopeLimit)
{
// push the player down along the slope surface
Vector3 down = Vector3.ProjectOnPlane(Vector3.down, hit.normal).normalized;
slideVelocity = down * slideSpeed;
}
}
void Update()
{
// ... normal movement into 'move' ...
controller.Move((move + slideVelocity + gravityVelocity) * Time.deltaTime);
slideVelocity = Vector3.zero; // reset each frame
}
Reset the slide each frame so it only applies while you are touching a steep surface. The first person controller tutorial shows the full CharacterController movement loop this plugs into.
Fixing Bouncing Down Slopes
When the character walks downhill, horizontal movement carries it off the surface and it drops back down in a series of small falls. During each fall, isGrounded flips to false, which also breaks jump logic and footsteps. Three fixes:
- Apply a small constant downward velocity while grounded. Set vertical velocity to about -2 instead of 0 when
controller.isGroundedis true. This keeps the capsule pressed into the ground. - Project the movement onto the slope as shown above. Moving along the surface prevents leaving it in the first place.
- Snap to the ground. After moving, if you were grounded last frame and are not now (and you did not jump), raycast down a short distance and move the character down to the hit point.
For Rigidbody characters, the same idea applies. Project the velocity onto the slope plane, and when going downhill add a small extra downward component so the body hugs the surface.
Steps and Stair Climbing
CharacterController handles stairs through Step Offset, as long as the step height is below that value. Rigidbody capsules do not. A low step stops the capsule dead, because it hits the vertical face. The simplest fix is to make the stair collider a single invisible ramp, with the stairs mesh used for visuals only. Put that ramp on a layer the player collides with (see the collision layers matrix guide) and choose a friction that suits you.
📚 Learn the physics behind it
Friction, normals and projection show up in every movement system. Our list of programming and game design books has approachable picks that explain the math.
Troubleshooting
Player slides down slopes when standing still
A Rigidbody with low friction slides. Turn off gravity while grounded on a walkable slope, or raise the friction on the ground material. For CharacterController, nothing slides unless your code applies it.
Player sticks to walls and won’t fall
The player collider has high friction. Use a zero-friction material with Friction Combine set to Minimum.
Player is slow going up slopes
The movement vector is horizontal, so the slope pushes back. Use Vector3.ProjectOnPlane(move, normal) with the ground normal.
Character bounces going downhill
The character leaves the surface each step. Apply a small downward velocity while grounded, project movement onto the slope, or snap to the ground.
CharacterController won’t climb a ramp
The ramp is steeper than Slope Limit. Raise Slope Limit or lower the ramp angle. Also check that the ramp’s collider is not a rough mesh collider with tiny steps.
isGrounded flickers between true and false
The controller is hovering because of Skin Width or because you set vertical velocity to exactly 0. Use a small negative value like -2 while grounded.
Jump does nothing on a slope
The slope logic is turning gravity off and keeping Y velocity from the projected move. Skip it for a short time after pressing jump.
FAQ
What is a good maximum slope angle?
45 degrees is the Unity default for CharacterController and a fine starting point. For realistic games, 35 to 40 degrees feels more natural.
Should I use a Physics Material or code to stop sliding?
Code is more reliable. Friction values interact with whatever surface you stand on, while a ground check and a gravity toggle behave the same everywhere.
Why does my character slide on perfectly flat ground?
Usually something is adding sideways velocity, such as a moving platform, a leftover force or an animator with root motion. Watch the Rigidbody’s velocity in the Inspector’s Debug mode.
How do I get the slope angle?
Vector3.Angle(Vector3.up, hit.normal), using the normal from a raycast or from OnControllerColliderHit.
Does this work in 2D?
The idea is the same. Use Physics2D.Raycast, take the normal, and move along Vector2.Perpendicular(normal). Rigidbody2D also uses a Physics Material 2D with friction.
Reader questions
Asked by readers of this article and answered by AI. Behavior can differ between Unity versions, so test in yours.




Leave a Reply