I've been trying to make my character unable to go up steep hills, but I just can't manage to make it work. I'm using a simple height map which stores the height for every (x, z) point within the map. I've tried to do this(using C# and XNA):
float height1 = TerrainHeightAt(cam.Position); float height2 = TerrainHeightAt(cam.Position + cam.GetVelocity()); //If the difference between the two is bigger than a certain constant, don't move.
Basically I find the current height and the future height of the camera. Then, I check if the character is attempting to go up a too steep hill, and if so, I prevent the character from moving. This is not working and I can't see why it isn't.
So my question is: What am I doing wrong? I would appreciate any link(specially using XNA, but general articles would be great too) showing how to achieve this.