Walking up the hill..

I have a terrain made of a heightmap and a md2 character that walks on the terrain. I get the height of the terrain and set this as the y value of the character.
(ymodel = GetHeight(-zmodel , xmodel )+30;)

Know the problem is that when the model walks up the hill, his feet go through the hill.
Raising the +30 (standard height on flat terrain) does help but then the character “fly’s” above the terrain.

Is their something i am missing or have i do some other calculations (angles, normals etc).

Can someone explain this to me or point me in the right directions.


when the terrain grid is not very dense, you would need to interpolate the height between “heightmap pixels” yourself.
so you would lerp between the height of the current grid pixel and the next one.
your heightmap is “discrete” ie you have little steps (pixels stand for a height).
while your triangle takes those pixels as vertices the surface between pixels doesnt make “steps”

so when your character moves between grid’s steps, you need to interpolate yourself