I'm trying to implement simple 2D circle collision system. There are circles with different radiuses and velocities (the larger the circle the slower it is). Contrary to all the questions on the Stack, the circles do not bounce at all.
There is no problem with collision response for two circles that overlap. There are two approaches that I thought of:
- Pushing the circles apart with displacements dependent on the ratio of circles' radiuses.
- Pushing the smaller circle away so it doesn't collide with the bigger circle anymore.
However, neither of these approaches works for multiple circle collisions. Let's consider an easy example:
Three circles are moving towards the same point but with different velocities:
In the next frame they overlap like this:
Then with either of the two approaches the smallest circle gets pushed away from the biggest one:
And then the right-most circle would push the smallest circle to the right making an infinite collision loop.
Of course, the more circles, the more complicated the collision resolving would be. Additionally, I'm going to add static walls thus making collision system even more complex.
What algorithm can I use to make multiple collisions work? I guess that the desired effect would look like this: