Rotating character based off of ground's rotation.

I am using a rigidbody character in my first person game. It is currently set to be affected by gravity on its local down, so gravity is dependent on its rotation. How would I rotate my character as it walks up this ramp so that it can effectively switch surfaces.

I think that you can do on this way:

To detect ground and rotation, you can raycast down each frame and set the object up vector to hit normal vector.

I think that this could work

transform.up = raycastHit.normal;

For gravity you could disable default gravity (Vector3.zero), and manually apply a force/movment to down vector.