Collision detection with heightmap based terrain

Posted by Truman's world on Game Development See other posts from Game Development or by Truman's world
Published on 2013-01-26T22:00:46Z Indexed on 2014/05/28 4:09 UTC
Read the original article Hit count: 326

I am developing a 2D tank game. The terrain is generated by Midpoint Displacement Algorithm, so the terrain is represented by an array:

index --->  height of terrain
[0]   --->  5
[1]   --->  8
[2]   --->  4
[3]   --->  6
[4]   --->  8
[5]   --->  9
...         ...

The rendered mountain looks like this:

        *
  *     * *
  *     * *
  *   * * *
* *   * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * *
0 1 2 3 4 5 ...

I want tanks to be able to move smoothly on the terrain (I mean tanks can rotate according to the height when they move), but the surface of the terrain is not flat, it is polygonal. Can anyone give me some help with collision detection in this situation?

Thanks in advance.

© Game Development or respective owner

Related posts about collision-detection

Related posts about terrain