iDevGames Forums
How would you do *real* collisions? - Printable Version

+- iDevGames Forums (
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Programming Languages & Scripting (/forum-8.html)
+--- Thread: How would you do *real* collisions? (/thread-3406.html)

How would you do *real* collisions? - leRiCl - Mar 19, 2007 03:12 AM

Currently, I just have an object, which checks constantly if there are any other objects within a certain radius; if so, it is colliding. This is what i did for a game where there is no 'bouncing'... but what if you want bouncing? what then?

How would you do *real* collisions? - OneSadCookie - Mar 19, 2007 03:35 AM

Well, you're going to need to know their masses, centers of gravity, relative velocity, and the point of impact, and a good knowledge of high-school physics...

Personally, I tend to think that's a bit too hard, and go for Chipmunk or Newton or something like that to do the hard work for me Smile

How would you do *real* collisions? - Skorche - Mar 19, 2007 08:54 AM

Ah the sweet smell of vindication. Gives a person that warm fuzzy feeling.

Depends on how complicated you want to make it. Writing the physics for a pool game wouldn't be that hard. You could write that in a hundred lines probably. Jakobsen style physics are also pretty easy, and relatively powerful. (google is your friend)

Writing a robust and stable rigid body physics engine is not simple though. If you are really interested, I could find some of the resources and papers I read when creating Chipmunk.

How would you do *real* collisions? - Aressera - Mar 19, 2007 05:29 PM

I'm in the process of writing a full 3D physics engine right now and i've found this book invaluable: Dynamic Simulations of Multibody Systems. Try to see if its at any local university libraries or similar high level institutions. It basically will tell you almost everything you need to know.

I also recommend reading the articles written by Chris Hecker here.

That should give you a good starting point for at least understanding how things work, though implementing a good engine is difficult at best.

But for your original question, as OSC said, you'll need to know the relative velocity at the collision point, the collision point, the collision normal, the masses of each body, and the inertia constant for each body. Then you'll have to use that to calculate the impulse on each body in the direction of the collision normal and apply the impulse to get final angular and linear velocities. (you can omit the angular components if you're just using spheres)