Moving Character Down a Ramp

I’m having this odd problem with my side-scroller game.

I’m using CharacterController and I have a 20degree ramp made of a plane. When I move down the ramp my character “bumps” down as if he’s going down stairs. When I go up the ramp everything is fine. The problem is that while he is “bumping” he loses ground contact and loses the ability to jump.
If I increase the gravity substantially (from 30 to 150) the bumping goes away, but I need the lower gravity for my gameplay.

Any work arounds you can think of?

Here’s what I do.

This makes the CharacterController ‘snap’ down onto the ground when they are just above it.

I use this in the Update() method on a script that’s attached to the CharacterController object.

CharacterController controller = GetComponent<CharacterController>();
float snapDistance = 1.1f; //Adjust this based on the CharacterController's height and the slopes you want to handle - my CharacterController's height is 1.8 
RaycastHit hitInfo = new RaycastHit();
if (Physics.Raycast(new Ray(transform.position, Vector3.down), out hitInfo, snapDistance)) {
    isGrounded = true;
    transform.position = hitInfo.point;
    transform.position = new Vector3(hitInfo.point.x, hitInfo.point.y + controller.height / 2, hitInfo.point.z);
} else {
    isGrounded = false;
}

I keep an isGrounded variable to keep track of whether the character was snapped to the ground or not - I use this instead of the normal controller.isGrounded for controlling animations and whether or not the character may jump.

Sounds like maybe you have a box collider / rigidbody character? Try using a CharacterContoller instead, and adjust the slope limit. If you insist on a rigidbody, try using a capsule collider, and adjust the angular drag so he doesn’t fall over. You can also use rigidbody constraints. You could also increase the ray distance, if you are using a raycast to detect if the player is grounded. So if you have, persay, Physics.Raycast(transform.position, down, hit, 1), try (Physics.Raycast(transform.position, down, hit, 5)… Of course experiment with amounts. Hope this helps. If it doesn’t, you should post your code so I can check it out and go from there.

Hey, it’s a very old post but I thought I could help people who encounter this problem.

If your “Game Object” has “Rigidbody” component and behaves abnormally, you should probably check your script to see if you are changing the values of “velocity” or “transform.position”.

Note that if you want “Physics” to work perfectly you should always work with “AddForce”. (Or ignore AddForce completely and find other ways to implement a solution. There are very cool tools to use in Unity. Such as Vector2.Lerp/Vector3.Lerp, Vector2.MoveTowards/Vector3.MoveTowards. See documents.)