• Advertisement
Sign in to follow this  

Terrain Collosion

This topic is 3408 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

Hey, I am creating a top-down style game that is *not* tile based. The terrian i use is a basic heighmap. So i am wondering how to create a 2-dimensional collision map from a heigh map. I for example want areas with an angle above 45 degrees not be passable. greetings, Halan

Share this post


Link to post
Share on other sites
Advertisement
For my terrain I use ellipsoid (player) vs polygon collision.

By getting the players x,y position, I can quickly determine which polygon in the terrain the player is standing. I then check collision with that polygon and the surrounding ones (to a certain threshold).

If the normal of a polygons angle is > 45 degrees then i cause the player to slide down the tile if the angle is less than 45 degrees then I only offset the players y-position to sit on top of the terrain and don't modify x and z to prevent the player sliding down shallow slopes.

Share this post


Link to post
Share on other sites
Yeah i wanted the player collosion to be a simple circle as it is easy to be calculated. I think i also don'T need the slidign down as i want to have natural boundaries in my game world.

I think i willl just go for squares the player will collide with.
Basically if one of the squares edges is higher than 1 meter compared to the other i will it make collide with the player.

Is that a nice behaviour?

greets,
Halan

Share this post


Link to post
Share on other sites
I think the most simple way to check for >=45 degree angles is to check whether the height difference between the cell("tile") you're standing in and the target height point/vertex is greater or equal to the width/depth you have defined for your terrain cells.

In case that didn't make sense (and I'm sure it didn't): if for example your cells are 5.0 units wide and deep, any height difference between two points being >= 5.0 would also make their angle >=45 degrees. So in your case choosing 1.0 might or might not work, depending on how large your terrain cells are (if they were 100x100 for example, then a difference of 1.0 wouldn't even be visible, slope-wise).

I don't have the actual math to back this up, it just logically/visually seems to make sense to me. Someone please correct me if I'm wrong here :)

Share this post


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

  • Advertisement