Rotate a vector3 to a surface normal?

Hello,

I am trying to stop my character controller from hopping down slopes and I was told that i should rotate my movement vector to the normal of the ramp to stop this. However, I am not sure how to do this and I require some help. I am fairly new to unity and would greatly appreciate any help :stuck_out_tongue:

You can match the rotation of the slope, assuming the slope is a rectangle, like so:

private void OnCollisionStay(Collision collision)
{
    transform.rotation = collision.collider.transform.rotation;
}