Jump to content
  • Advertisement
Sign in to follow this  
_Unicron_

Efficient height calculation for walking on terrain

This topic is 3682 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
Advertisement
Depends what you want to achieve, but interpolation will basically give you the height under the player's feet. That can be enough (guild wars seems to do something similar). It's also very fast of course.

Share this post


Link to post
Share on other sites
Yes, thats the basic effect that I am trying to achieve at this moment. I just wanted a more experienced opinion before I started the implementation. Thanks for the quick reply ++rating

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!