Jump to content
  • Advertisement
Sign in to follow this  
Pufftek

Questions about collision detection

This topic is 2438 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'm fairly new to the world of 3d programming, so please forgive me. I cannot really find any good tutorials on 3d collision detection (i'm using Lwjgl), but I think I have it somewhat figured out on my own. This is how I would do it: each update, check the coordinates of the object against the coordinates of the other existing objects. If they intersect, do the event. For example, if a player object intersected a wall, set the player object's coordinates to the outside coordinates of the wall, therefore making it appear solid. Is this somewhat the correct way to do this?

Share this post


Link to post
Share on other sites
Advertisement
3D collision detection is fairly complicated. 3D collision response (fixing the collision after detected) is very complicated. Doing interesting physics with these events (from bouncing balls to complex constraint-based physics) is insanely complex.

There are a number of books on the topic. There are also Open Source libraries to learn from, such as Bullet.

If you're looking to use physics without digging into the details and writing it all from scratch yourself, you are far better off using an existing physics library. Bullet is quite serviceable. There are others. If the game is a free/hobby project, I believe you can even use Havok or PhysX freely.

Share this post


Link to post
Share on other sites
Is this somewhat the correct way to do this?
It is the correct way to do it. Well, it was.
It is no more considered sufficient those days and a lot, a lot of things can go wrong. Trying to make my physics subsystem (back when physics engines were new) is possibly the 2nd major error I did. The 1st is spending too much time on terrain algorithms.
I strongly suggest to find bindings for some ready to go physics library and the language of choice.
Let me elaborate.
If they intersect, do the event. For example, if a player object intersected a wall, set the player object's coordinates to the outside coordinates of the wall, therefore making it appear solid.
I take for granted 'do the event' means something involving to notification and re-positioning.
Here are a few things that could go wrong:

  1. Quantum tunneling: timestep is too long, collision is missed
  2. Quantum tunneling (opposite encroaching vector): collision is detected but encroaching is so deep the object is pushed out the wrong side
  3. Instability: when it comes to floors, the object will continuously "jump" on top.

Even with a ready to go physics library, (3) has been a serious concern for me. I have managed to hide this for the time being but it's only a duct-tape solution... and I still have no idea on how to fix this.

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!