I think I have a way to do this, and it's even (sort of) geometrically correct. I'll try to put it up after work. Or if you can find the basic vector math stuff yourself, here's the procedure:
PlayerVec = The vector direction the player is moving.
PlayerUpVec = The vector normal to the surface the player is on. The normal sticks out of the ground perpendicular to it.
given it's a half-pipe thing, I'm assuming these two are perpendicular; this won't work if they aren't.
Normalize(PlayerVec) ; makes the length of the vector 1
Normalize(PlayerUpVec) ; same
tempvec = PlayerVec (cross) PlayerUpVec
; tempvec is the cross product of PlayerVec and PlayerUpVec
; this vector points to the player's left or right. Add a minus sign to swap sides.
PlayerVec = LinearInterpolation(tempvec, PlayerVec, 0.1)
; Set PlayerVec to be the linear interpolation between tempvec and PlayerVec
; this "blends" between the two vectors, turning PlayerVec 10% (that's the 0.1) toward tempvec.
; to turn faster, use 0.2 or something.
Normalize(PlayerVec); make length 1
PlayerVec = PlayerVec * PlayerSpeed
; PlayerSpeed is a float, telling how fast you want the player to move.
So all you need is a normalize function, a cross product function, and a linear interpolate function.
:D
PlayerVec = The vector direction the player is moving.
PlayerUpVec = The vector normal to the surface the player is on. The normal sticks out of the ground perpendicular to it.
given it's a half-pipe thing, I'm assuming these two are perpendicular; this won't work if they aren't.
Normalize(PlayerVec) ; makes the length of the vector 1
Normalize(PlayerUpVec) ; same
tempvec = PlayerVec (cross) PlayerUpVec
; tempvec is the cross product of PlayerVec and PlayerUpVec
; this vector points to the player's left or right. Add a minus sign to swap sides.
PlayerVec = LinearInterpolation(tempvec, PlayerVec, 0.1)
; Set PlayerVec to be the linear interpolation between tempvec and PlayerVec
; this "blends" between the two vectors, turning PlayerVec 10% (that's the 0.1) toward tempvec.
; to turn faster, use 0.2 or something.
Normalize(PlayerVec); make length 1
PlayerVec = PlayerVec * PlayerSpeed
; PlayerSpeed is a float, telling how fast you want the player to move.
So all you need is a normalize function, a cross product function, and a linear interpolate function.
:D