Good 2D Collision Response References

26,016

Solution 1

The N tutorial that you mentioned already is a great resource to start with. I also recommend the very good article 2D Polygon Collision Detection. It comes with a great C# implementation and example for polygon collision detection using the Separating Axis Theorem and explains some of the concepts better.

As far as responding to a collision is concerned it depends on the scenario. For games you might want to check for a possible collision based on the current velocity and then simply adjust the actual velocity to prevent collision. You could also implement some sort of 'bounce' effect. In any case it will likely be adjusting both the velocity and direction of the object.

You can use the Separating Axis Theorem to do the collision detection and also use polygon projection to find the distance to the target on a specific axis. (most of the time the vector on which you move).

Solution 2

I really like this one, it just arrived a week ago and it's everything you could want short of doing relativistic effects:

http://www.amazon.com/Physics-Game-Programmers-Grant-Palmer/dp/159059472X

Solution 3

How much detail do you need? Answering some of these questions would help you eliminate packages that don't do what you need.

Do you have to worry about object rotation? Then you need to be concerned about lever arms, angular momentum, moments of inertia, and torques.

Do you have to worry about deformation? Then you need to get into finite element analysis, stress/strain, etc. -- something that describes how the objects respond internally to external forces.

What about frictional effects? Then you'll need coefficients of friction, or possibly velocity models for air resistance.

Gravitational effects? Electromagnetic effects? Other forces?

Solution 4

If you want a basic answer for collision response, here it is :

for each pair of objects that collide
    ask gently to the collision detection lib their interpenetration distance
    Apply an impulse (i.e. a force in the duration of the frame) to both objects :
        force proportional to penetration depth (you will have to tune the coef by hand)
        direction : perpendicular to the collision normal.
        application point : the collision point (approximately, since it s not a point anymore but a volume)
integrate (Euler, Verlet, )\
Share:
26,016
Jeff
Author by

Jeff

Workin on some Access DB, doin a few other things as well. Going into 3rd year Uni. Interested in games, currently trying to make a little game in XNA with intentions of porting to Silverlight/whatever else, mainly for experience. I really like coming up with odd game play ideas, so I figured going into CS would be the best bet to learn enough to make my own game. Maybe not an actual game, but certainly to prototype ideas I've had, see if they're fun enough and what not. If you have any suggestions to a beginning game designer, please PM me! :D

Updated on February 01, 2020

Comments

  • Jeff
    Jeff over 4 years

    Hey, I'm currently looking for various methods of implementing collision response in 2D video games, something similar to this tutorial Metanet has: N Tutorial I'm looking to implement something in XNA, but any language would be fine. I'm more interested in implementing programmatically than actual theory. I'd prefer more beginner friendly material, but I do welcome more advance topics.

    So could someone suggest some good 2D collision response articles/books?

    (PS: I'm more interested in response than detection)

  • Jeff
    Jeff almost 14 years
    I'm less interested in doing realistic physics and more interested in how you deal with the actual collision (like how N uses projection). I guess what I'm looking for is the bare bone basics, nothing complicated. I have looked at Box2D and heard of Farseer, and they do look pretty good and I'd definitely resort to one or the other if I decided to make a physics based game. Box2d is on Flash as well.
  • Jeff
    Jeff almost 14 years
    I literally just want basic response. Some tutorial that implements something like Mario 3 for example would be fine (although the New Mario has some pretty fun physics...). I want to know what they do to respond to collisions. Do they produce a minimum correction vector and move out? Do they use little springs? But most importantly I'm looking for HOW they implemented this. The N tutorial I posted is pretty close to what I'm looking for, but I'd rather something more in depth.
  • Jeff
    Jeff almost 14 years
    I have heard of it. What's it do collision wise? Also, not really what I'm looking for, but thanks :)
  • gWaldo
    gWaldo almost 14 years
    I'm not sure what environment that you're developing in, but Cocos2d can be used for the Mac and iPhone, but I'm not sure what else it can be used for (if any.)
  • Jeff
    Jeff over 12 years
    I find this C# version to be a better resource. The tutorial goes more in depth about projecting a polygon onto an axis, which I find the N tut misses. If anyone has any confusion from the N tut, check out this C# one.
  • redcodefinal
    redcodefinal almost 11 years
    cocos is for apple products, not XNA