character controlling script

hi how i can make the character walk on the wall or walk up or down a hill with its rotation correct like this img

alt text

Try using 2 ray casts.

Cast one ray down from the characters position.
Cast the other ray down from 1 meter in front of the character.
Compare the difference to compute the slop.