Collision between BoxCollider2d and PolyhgonCollider2d causes jittering

I have a very simple 2D scene where the player character can jump and land on a box. This is done entirely with gravity, so jumping just adds a force and Physics does the rest. There is no manual movement in the code or anything. The player character collider is a BoxCollider2d and a dynamic body, the box is a static body.

If the object the character lands on is also using a BoxCollider2D then everything is fine. If I change it to a polygon or composite collider, however, the collision becomes unstable and the character jitters endlessly.


(the static line is the composite collider, the moving one is the box collider from the player character)

None of the solutions I found so far help (velocity threshold, contact offset). Does anyone have any tips on how to solve this?

Using Unity 2022.3.3f1

This is far from normal and just doing what you’re saying you’re doing shouldn’t produce that i.e. just adding a Rigidbody2D with a BoxCollider2D falling onto a Static shape and not changing any global settings or TimeManager settings etc.

If you can reproduce this in a new project then can you please zip it up (delete the library folder first) and upload here so I can take a look?

1 Like

Thanks for getting back to me. I tried to reproduce it in a new project but could not. So I went back and looked through my scripts again.

Turns out it was a kind of race condition with my logic allowing the player to jump through the object from underneath but being able to stand on top. Basically I ended up toggling IgnoreCollisions on and off with every other update respectively… :confused:

I didn’t find this the first time around because there were so many Google entries for jittering collisions that I defaulted to that as the obvious reason. Sorry for not investigating thoroughly enough before wasting your time.

1 Like

Not a waste of time if you found the issue. Always good to test in isolation! :slight_smile: