# *cries* Collision question

This topic is 5172 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 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 on other sites
Thanks for your help, both of you, it's off to google. [smile]

##### 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 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.

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 20
• 14
• ### Forum Statistics

• Total Topics
632950
• Total Posts
3009385
• ### Who's Online (See full list)

There are no registered users currently online

×