Sign in to follow this  

collision reactions

This topic is 4837 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

ok im doing a box bounding collision detection and i need to have it so that when one sprite hits another one it will bounce off my velocity and positions are stored as points though so you cant just subtract or call the invers of the x or y value and the thing your colliding with can be hit from any angle so i was just wondering how you would code this thx. if i wasnt clear enough let me know.

Share this post


Link to post
Share on other sites
The most realistic way is to use an elastic collision:

Combined momentum of objects is constant before and after collsion:

m1v1 + m2v2 is constant,

where m1 and m2 represent the masses of the respective objects,
v1 and v2 their velocities.

Combined kinetic energy of objects is constant before and after collision:

Ek = ½mv2

Ergo:

½m1v12 + ½m2v22 is constant


Using these formuale (or a derivative of them) will produce the best, most realistic collisions. If you don't understand any of the italicised words, google them, or don't use this approach - it involves physical mechanics.

Next time, [google] or gd search before posting - this has been answered many a time before. If you still can't figure it out, you should look back at these resources before posting again, and you should always sit down and experiment with your problem until you find an adequate solution. Having people hold your hand as you program is no way to learn.

Regardless, best of luck in your endeavours.


Mushu - trying to help those he doesn't know, with things he doesn't know.
Why won't he just go away? An question the universe may never have an answer to...

Share this post


Link to post
Share on other sites
if you're trying to do something simple, you might want to determine the straight line along which each vechicle is travelling, and then swaping the sign on the slope and using the new equation to determine the next point.

Share this post


Link to post
Share on other sites

This topic is 4837 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this