Sign in to follow this  

2D collisions between objects.

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

Hi. I am making an algorithm for collisions between two objects, whose boundaries are delimited by a rectangle (AABB). Now, I was thinking each object should handle his collisions how he sees fit. So he receives a message that he collided and who he collided with. My question arises on the following example. Rhino 1 is going left, velocity is x=-1 y=0, and Rhino 2 is going right, velocity is x=1 y=0. I want each rhino to change to a random direction(except the current one) when they collide. What happens is that i'm making each Rhino advance till they overlap, and on the OnCollisionMessage(sender, receiver) event i get what direction they were facing, and I substract the velocity before changing the direction. Rhino 1 would first add 1 to Rhino1.X and then choose a random direction. Rhino 2 would decrease Rhino2.X by 1 and then choose the direction. What happens is that if i have several other objects on the map, this scheme is totally messed up, since on one side there could be an overlapping object, and then when substracting the velocity to the position, the new position overlaps with the other object, making it impossible to fix. If you don't understand this, i could post a pic. Either way, do you have any suggestion as how to tackle this problem? Are the objects supposed to manage the collisions by themselves, or should there be an omnipotent class that will handle all collisions of objects and reposition them as it sees fit? I kinda reached a dead end and i'm clueless which way I should continue. Thanks in advance!

Share this post


Link to post
Share on other sites
math and physics anyone?

either way, resolving interpenetrations is no trivial subject, and i doubt there is an answer that can be contained in a single forumthread.

an encompassing class handling this seems easier to me, but then again that could be my lack of OOP knowledge.

Share this post


Link to post
Share on other sites

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