Collision handling improvements

Hello guys,

I tried to build my own collision process and got some great results.
But now I don’t know how to fix the last issues I have.
The code can be downloaded here: https://github.com/EnemyArea/CollisionHandling
Feel free to use it for whatever you want.

To be more concrete, I have some issues with the jittering if there are more than two collisons at the same time.
Please take a look at this picture:

You see the two yellow circles. The circle on the bottom is the “player”. Now, you would like to pass between the wall (right) and the circle (left). But the gap is not large enough. The collision system now tries to push the player back, but that cause some ugly jittering… Any ideas how I could fix that?

The next issue is, how to handle collisions when the objects are moving.
I have a circle (static) and one circle, which one is above that circle and is moving up and down. Now the player got between theese two circles and should be pushed down by the moving circle. Now the three circles stuck, because the player cant move down:

Greetings
Kai

I’d say you want to do a shortest distance collision check and adhere to the closest surface collision before updating. In some situations it could be that adhering to the closest surface could cause another collision of sorts so it would have to resolve the new closer surface intersection before updating (could use recursion - in some unusual circumstance you may want an iteration limit where it starts shortening to original motion vector to prevent glitches where u get trapped between a bunch of things if using the original velocity vector). So then only update the visible frame after a good closest solution is found.
For the second part where the circle gets trapped - I’m not sure if I understood the problem. Maybe the moving circle just needs to change its direction when a collision is detected?

Hello,

thank you for the reply. You are right, that fixed the jittering issue. I have updated the develop branch. Thank you very much :smiley:

yes, I think thats true, ignore that :wink: I have to adjust the engine.

Greetings Kai