All you have to do is get ground height where your character is, just to the right of your character and just in front of your character. You should subtract them to get a (sort of) gradient:
charh#=get ground height(1,object position x(1),object position z(1))
forwh#=get ground height(1,object position x(1),object position z(1)+0.1)
righth#=get ground height(1,object position x(1)+0.1,object position z(1))
xgradient#=righth#-charh#
zgradient#=forwh#-charh#
Then from gradient values, you can work out which way your character should slide and how fast.
I made a program to do sliding. It might still be in the code snippet forum.