Questions about collision detection
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?
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.
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.
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:
- Quantum tunneling: timestep is too long, collision is missed
- Quantum tunneling (opposite encroaching vector): collision is detected but encroaching is so deep the object is pushed out the wrong side
- 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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement