Smooth Terrain Following - Tips / Techniques?

Hey guys. So I have been bashing my brain in for about a week now. Basically my situation is, I am trying to implement a terrain following character, similar to WoW. If you haven’t played it before, these are it’s charactersistics -

  1. While grounded, the user always stays grounded. Meaning, if the user walks down a somewhat steep slope, the player will stick to the ground no matter what.

  2. If the ground beneath them is too steep, they go into “slide” mode and slide down it.

  3. You can jump any time you are grounded, but not while sliding.

Seems simple right? Well, I have been trying to hack apart the FPS Character controller because it doesn’t quite behave as expected. If I am on a somewhat steep incline and walk up it, no problem it works great. The problem is with declines, if I walk down the same incline, the controller “bounces” down, since the forward velocity is greater then the gravity pulling them down.

I have all the different aspects working, but I can never get all of them to work at once. I have tried:

  1. Raycasting from the player to the ground, finding the hit point and placing the player on the ground. Works great except if the player walks down a somewhat steep stair then they instantly snap to the ground instead of walking smoothly down it.

  2. Modifying the angle of movement. So instead of pushing the player forward, I tried to angle the forward vector with the terrain normal using cross products. Works somewhat ok, but there are certain rotations where cross product doesn’t seem to get the correct forward vector, it is slightly skewed.

Have any of you experienced this issue of a bouncy character controller while walking down slopes? How were you able to reconcile it? Im looking for ideas to push me in the right direction, so any tips / techniques are welcomed. Also if anyone knows of any online articles that deal with this matter, I would be very interested in reading them. I searched gamedev.net but came up with nothing other then basic collision detection.

Thanks again for your time! Cheers!

Ok so I believe I have found a solution. Basically the part of the FPS walker script that deals with the gravity . . .

moveDirection.y -= (gravity * Time.deltaTime);

basically I am having it check if the controller is grounded or not, and depending on the grounded status, it applies a different type of gravity.

So if it is falling in the air, I preform the original method of gravity. If it is grounded, my gravity calculation is:

moveDirection.y -= 2;

For some reason using Time.deltaTime is causing jittery calculations for the move direction . . . not sure why. I am drawing a ray that represents the move vector and I can see it bouncing around like crazy, yet when I use my new method it works smoothly.

Basically, this modified the gravity to always be pointing down and roughly a little more then -45 degrees. If you want your character to move up and down even steeper cliffs, then you’d have to lower the Y value even more.

Ok, now with that solved, onto more figuring stuff out lol . . .