Improve the character controller

The character controller is still terrible when moving on a sloped surface. The character bounces when going down a slope as the movement speed is faster than the falling speed caused by the game gravity. With the addition of a landing animation the result is jarring, the character lowers their weapon after landing disabling the ability to shoot momentarily.

Assume the WASD key will result in a movement basis vector multiplied by a speed value in the direction of the “x” and “z” axis, while the spacebar will make the character move in the “y” axis.

Cast a ray from the middle of the character’s body to the ground, if the length of that ray is more than half the character’s body length that mean the character is on a slope.

When on a slope the character movement basis vectors would look like this relative the the slope normal “N”.

So when the game detects that the character is moving on a slope the vertical basis vector should be rotated to align with the slope normal. This will also align the xz plane to the slope surface making slope movement smooth.

Rotating the vertical basis vector should only be done when the character is on a slope AND moving, if the character is standing still on the slope pressing the spacebar should still make the character jump vertically instead of leaping forward down the slope.

6 Likes