Sign in to follow this  

*cries* Collision question

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

Let's say we have 4 objects, all in a row. There is no room between them. The 2 right-most objects move a little to the left the same amount. So, when we detect for collision, we see that the left-middle and right-middle objects are overlapping (not allowed). You may be seeing where I am going. After you move back either object to where they are allowed to be (let's assume the objects don't get harmed when they collide in such a way), there is a new collision. Do you need to test for collision after each move, even moves that exist becasue of a previous collision?

Share this post


Link to post
Share on other sites
I think you should perform a collision check in the update of every object. So you would:
1. move objectA
2. Update objectA's collision
2a. If a collision occurs, perfom whatever action needs to happen to resolve that collision (most likely, moving objectA only a portion of the velocity vector)
3. move objectB
4. Update objectB's collision
4a. ...
...

Share this post


Link to post
Share on other sites
Collision detection is a geometric problem. What you are talking about is "collision response" which can be anywhere from quite simple up to a complicated physics problem. If you want a good physics "collision response" system then Google for "Rigid Body Dynamics".

Collision detection / response is done in a fashion such as with each frame you test your objects in turn to see if it is colliding with anything - e.g. world or surrounding objects (detection). If you want a simple response you could, for example, just push the object you tested back in the direction it was travelling until it is no longer colliding before rendering. Rigid Body Dynamics is much more complicated but looks much better in terms of collision response.

HTH

Share this post


Link to post
Share on other sites
generally speaking you'll want to make your collision detection recursive, to handle the situation you're describing. to ensure you don't get stuck in a permanent loop be sure and implement friction in your response system, as well as using a delta to determine an minimum amount of movement required before you execute your detection loop.

Share this post


Link to post
Share on other sites
Of course, you can also chicken out and just check/move once and leave it at that until the next frame. It's not very realistic but for a lot of games i would imagine it would work just fine and you would never know the difference.

Share this post


Link to post
Share on other sites

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