So I am trying to figure out a smart or elegant way to take a table of collidable objects and do collision checks on a each to all basis. But as I think about it, I am unsure how it will work out. I might have the first object colliding with two other objects. I could just have it handle collision on the first object from my list, and change its position appropriately. But then I don't do anything with the second collision.

Then, the second object from the array was colliding with the first, but now it isn't. So when we run the collision checks, we end up with no effect on this object. If I try to change the collision behavior to displace the two colliding objects instead of just the first one, then both might be out of collision with the third.

Anyways, I think I realize that all of this depends on how realistic the physics needs to be for your particular game. I just got confused in a hole of if then scenarios that began to escape my grasp. Any one have thoughts or methods for this type of problem?

P#36353 2017-01-22 15:13 ( Edited 2017-01-27 15:21)

What you'd usually do in a situation where resolving collisions may cause new collisions is to run the collision handling and checking code as many times as needed (Ofcourse with a limit to prevent an infinite loop which can happen).

What I usually do checking for collision and storing them in a list, then handling all of them.

 ```while there are collisions: ----handle collisions ----check collisions update positions ```

I make sure to check for their "future" positions, so checking for their positions with the velocity added to it. Then when handling the collisions I only change the velocities.

The velocity is then applied when there're no collisions left.

P#36714 2017-01-26 11:43 ( Edited 2017-01-26 16:43)

Thanks for the response. I was coming to that conclusion as well, an initial collision check that would build a list of colliding pairs, then move them, then check collision again etc. Also, I probably was amplifying the problem into the real physics realm where maybe you need to simulate thousands of particles colliding, and for a 8bit-ish game I should just focus on what is actually needed

P#36773 2017-01-27 10:21 ( Edited 2017-01-27 15:21)