I am creating a custom character controller that uses rigidbody physics to move around. At the moment, I can accurately calculate an acceleration vector that will move the player around, based on their inputs (WASD, shift, control), on the horizontal plane. The problem I am trying to overcome now is how to get them to move up and down slopes realistically. At the moment, the acceleration vector is only horizontal. What I am trying to do is get the normal of the terrain plane that the player is standing on (C), and rotate the acceleration vector (A) around the player’s local x axis (B) until it is perpendicular to the normal (C).
I’m pretty sure the solution will involve cross/dot products but if this is a solved problem, there is no point me burning brain cells over it!