Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


2D Collision Physics

This topic is 5680 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''ve got the detection part down pat, but I can''t figure out how to do realistic 2D collision between ship and asteroid. I know the law of conservative of motion, but not sure how to apply it. I''ve searched the forum, and all mentoined kinetic energy (I know what it is), but I don''t understand it. Can someone please explain in simple steps how it works? Thanks.

Share this post

Link to post
Share on other sites
Here's what I do:

Assume that both shapes are circles.

Find a momentum vector for each object (velocity scaled by mass)

Draw a line between the centers of the two circles (the "normal" line).

Use vector projection to project each objects' momentum vector onto the normal line. These represent how much momentum is transferred to the other object.

For object A, momentum = momentum - projection_a + projection_b;
For object B, momentum = momentum - projection_b + projection_a;

Find each objects' new velocity by dividing the new momentum vector by its mass.

Not entirely sure if this is 100% accurate (my equations are written with velocity and mass separated instead of momentum)

If you have more complicated objects, remember that all you really need is a surface normal vector to project momentum onto.

[edited by - Nypyren on March 4, 2003 3:01:31 AM]

Share this post

Link to post
Share on other sites
Hey thanks, that''s what I needed to hear

Mass and velocity are also seperate in my program.

How do I figure out the normal line?

X1,Y1 and X2,Y2 are the two points of the normal line right?
Is that all I need to make the line or do I have to know the angle or some other info?

I think I understand the projection part.

How do I split the momentum back into X,Y?

Take the angle of the momentum and use cos and sin to apply the momentum/mass?

Thanks for your help!

Share this post

Link to post
Share on other sites
Nevermind, I understand it now after a little researching on Advanced Bug''s code.

Thanks again!

Share this post

Link to post
Share on other sites
I found a problem with your physics, I notice that you add the new velocity to the ship/asteroid/whatever after colliding. This causes the both object to act like black hole, both pulling eahc other in. I changed it to subtract, and now it works perfectly! Thanks so much!


Share this post

Link to post
Share on other sites

  • 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!