Unity 6 Physics2D

I am testing my project in Unity 6, and I’m having issues with the 2D physics. Tthe Player can crouch, while crouching his capsule collider gets smaller (so he can fit through holes, or avoid bullets). But since updating, when crouching he can sometimes go through walls or the floor. This never happened before.
Setting the “Contact Threshold” from “0.01” to “0.001” helped a bit, but setting it lower won’t help. He’s still going through some walls and floor. Other times he’s not…

I am using a SpriteShape as ground with a PolygonCollider2D.

Changing the Capsule Collider like this (nothing fancy):

        CapsuleCollider.size = crouchCapsuleSize;
        CapsuleCollider.offset = crouchCapsuleOffset;

Moving the player has a long and convoluted script, but in the end I’m simply setting his velocity (worked in earlier Unity 2D projects without making him fall through the floor):

private void SetVelocity(Vector3 target) => Rb2D.velocity = target;

It looks like he falls through the cracks (see the gif and also the image with the SpriteShape PolygonCollider2D visible). This can happen on any green line/polygon intersection, or whatever you call it, on the SpriteShape.

I apologise, there was a bug introduced in 6000.0.1 however it has been fixed and hoping it’ll land in 6000.0.2. I’ll report back here if it doesn’t in which case it’ll land in 6000.0.3.

For now, simply set the ContactThreshold to 0 to turn this feature off and it’ll fix the issue. You can restore it to its default of “0.01”.

See here about when it’s not used:
https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Physics2D-contactThreshold.html

Again, sorry for the issue.

2 Likes

The fix for this has just landed in 6000.0.3f1 which is scheduled for release May 22nd - 24th.

Again, sorry for the issue.

2 Likes

No worries, glad to hear a fix is on the way, thank you for the quick reply!

1 Like

I’m having similar issues with Physics 2D in Unity 6 where collision detection is not handled properly. I’m on 6000.0.4f1 and I am having these issues.

It doesn’t matter if the collision detection is Discrete or Continuous, Interpolated or Extrapolated. My Character will now pass through any collider if it is moving fast enough (on dashing for example)

Nothing else has changed and the above feature doesn’t apply when using Discrete so this thread is unrelated and you have another issue.

Interpolation/Extrapolation are nothing to do with collision detection. They are a Transform thing for visuals only and do not affect physics at all.

I would recommend creating your own thread and posting some details of what you’re doing.