Jump to content

  • Log In with Google      Sign In   
  • Create Account

Pinpickle

Member Since 18 Jan 2013
Offline Last Active Feb 13 2013 01:04 AM

Posts I've Made

In Topic: An "AABB Physics Engine"

20 January 2013 - 12:25 AM

Hi there,

 

I wrote a series of articles about the process of creating a 2D platform game which uses AABBs exclusively for collision detection. Here is a link to the article which covered the collision detection and resolution:

 

http://www.wildbunny.co.uk/blog/2011/12/14/how-to-make-a-2d-platform-game-part-2-collision-detection/

 

There is some free downloadable source-code linked in the article as well which should get you off to a good start smile.png

 

Cheers, Paul.

I had actually read several of your other tutorials on my way to finding out how to do this and so far they have been a big help! I hadn't found that particular one so thanks for linking that to me - your blog is a wealth of knowledge.

 

I think I found out my problem was just how stubborn I was being when it came to implementing a more complicated solution. If I ever saw "collision resolving" or other terminology that I thought to be remotely scary in a tutorial I'd just sort of switch off, I thought there would be an "easier" way to do it. There really wasn't so I started making an engine the proper way and things are starting to slot together and I'm realizing just how simple a physics engine can be. It's been an awesome way of learning and I may post some code here once I get it really smooth.


In Topic: An "AABB Physics Engine"

19 January 2013 - 12:21 AM

The problem is that while axis-oriented rectangles look simple from afar, their response to collisions is full of special cases. If your objects will always remain AABB's, especially if they can go in any direction at any velocity, your collision code gets quite tricky. The first step clearly is to implement collision detection and collision response.

 

The first one is rather easy and I'm sure you've already found links, but here is one. The second one is not too bad because if you model your objects as rigid, frictionless, nonrotating entities, you can apply conservation of momentum and solve for the two objects' final velocities, using the normal of the colliding side (which you can get from  collision detection). See how it is done for two spheres and you should be able to solve for the general case (hint: the reason objects identical in every way except their shape collide differently is because they have different collision normals). Implementing friction on top of this is not too hard now.

 

If you are looking for documentation on how to implement physics for rectangular objects, you should google "rectangle" and not "AABB", because AABB's are often just containers for broad-phase collision detection which is not what you are looking for.

Thanks for the post, I'll do some reading up on "rectangular" physics instead. Me searching for things like AABB just proves how little informed I am in this world of physics programming - it's good to learn though!

I don't want my engine to be frictionless (to allow for moving platforms and such), how much more complicated do you think that will make it?


PARTNERS