Efficient height calculation for walking on terrain
4 replies to this topic
Members - Reputation: 438
Posted 15 July 2008 - 10:48 AM
I am creating a simple fps and Im trying to decide on the best method of determining the height of the player due to the terrain. The terrain is generated from a heightmap and so it is essentially a set of height values on a cartesian grid. With this in mind, I get the player x,z coordinates to find which height values are relevant with respect to the current player position. Now, Im unsure of the best method for determining the height. Am I better of using collision testing and pushing the player up when the bounding box collides with the terrain? or simply interpolating between the height values and setting the players height position (y-value) that way. Both methods seem to work to me but Im not sure which is the most commonly used approach (im leaning towards interpolation looking easier, but want to make sure Im not missing something), or if another method completely is used :)
Crossbones+ - Reputation: 1031
Posted 15 July 2008 - 11:27 AM
The smaller the objects, the more you can get away with using interpolation. However once your objects become bigger, the height at a single point will become a bad approximation and you'll end up with a lot of clipping if you don't handle the collision properly. I would stick with interpolation at least until it doesn't handle everything you need it to.