Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Collision detection - Donuts 3D

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

Hi, a while back I downloaded the directx 8.0 sdk and used the Donuts 3D sample to create my own game, Dark Mantra (get the game and source at http://www.angelfire.com/games4/glensoft/ but bear in mind it''s a bit old and I''m much better now generally lol). I loaded my own .x file and set the hilliness of the terrain to flat. The collision detection was achieved by a set of conditional statements, like so if (PositionOfShip > Top) { SetReverseMomentum(); } However, I''d like to use the sample to create a game with a character inside a cavern, so I can walk up and down slopes etc. I really don''t think using conditional statements is the best way to implement collision detection, so what would be best? if (witisism == !witty) return to_hole

Share this post

Link to post
Share on other sites
Well... you could still use conditional statements, but your conditions become a lot more varied.

For example, instead of testing for out of bounds, you''d be testing for movement against a gradient. Then you''d have to say something like:

If Gradient >0 and gradient < 45 degrees then retard motion.
If Gradient > 45 degrees, stop movement.

Alternatively (and much better imho), you''d use the normal of the terrain that the object is on to apply some proper physics to the object. This makes it much simpler because every frame, you''re just adding/multiplying the object''s delta by some factor of the normal.

And as for detecting the normal (or even which part of the terrain the object is on), just use a ray-intersect-triangle check, and if you get a collision, you can work out the normal.

Learning to fly is easy, but as a tortoise, the landings are really rough.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!