Character Jitter on Slopes

It’s my first time using a rigidbody for a character and everything is working fine, except that, when the character goes up or down a slope it jitters (a problem I never had with the character controller and the CharacterController.Move function).
Any idea is welcome.
I’ve already tried applying a small upwards/downwards movement when walking o a slope using Mathf.Tan(Vector3.Angle(contact.normal, character.up)) or something like that to get the exact amount of offset movement, it didn’t worked.

I assume you are using rigidbody.position for your movement, that’s why you are getting the jittering. Use rigidbody.moveposition instead, it’s designed especially for this. You may get jittering when you move down on a slope though, but that can be avoided by some tweaking.

If you’re using rigid bodies then you really ought to be using forces, or at least direct velocity changes, instead of directly manipulating positions. You pretty much throw away all the purpose of a rigid body otherwise.

It may help to apply forces (or position changes, if you must) exactly tangential to the ground plane. I can’t see “slopeCorrection” being set in your code so I don’t know whether you’re calculating it correctly or not. I wouldn’t use angles for this - your raycast gives you a ground normal, and you can project your character’s forward vector onto the ground plane fairly easily:

Vector3 groundForward = (transform.forward - groundUp * Vector3.Dot(transform.forward, groundUp)).normalized;

In any case though, if you use forces it should be more tolerant to being moved not exactly along the ground, which is obviously important for dealing with bumpy terrain.