# Collison Detection with fractal landscape?

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

## Recommended Posts

Hi, I need to make a check to see if an object has collided with a randomly-generated fractal landscape. Any ideas how to manage this?

##### Share on other sites
So, you have a function that given an (x,z) returns a y value, correct?

You can use the x,z to work out which grid square the point is in, and then which triangle it's in (we're talkng 2.5d here, so think of it more as a vertical line intersecting the x,z).

Once you know which 3 points make up the triangle, feed their x and z into your fractal function to get the heights.

Now you have 3 points you can use with the plane equation to find the ehight at the exact x,z you wanted to test.

This way is simplistic, but will work well with procedural terrain because it's procedural itself.

##### Share on other sites
...and if you're doing more than a point check, you can expand the above by basically constructing a temporary mesh out of the triangle directly underneath and its neighbors (for example, 3x3 grid squares). Then you can do a collision test between this mesh and the object hopefully using the same code as regular object-object collisions. A cheap optimization is to save the terrain collision mesh for each moving object and only reconstruct it if you move to a different grid square.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
634131
• Total Posts
3015725
×