Why is dynamic 2D collisions not precise

Let’s say I have a dynamic 2D rigid body(coordinates: 0,5), and a floor that is static (coordinates: 0,0).
If I run the project, the dynamic will fall, but for some reason, it will get in the floor so his coordinates will be (0,-0.1)
Then it will get up so his coordinates are (0,0.1) and then he stays there.
I thought that it happens because the object needs to fall lets say 0.2, so he dose not have enough space,
and so:

if(distance <= rb.velocity.y * Time.fixedDeltaTime) rb.movePosition(new vector2(0,distance))

But no, does not work.

The imperfection is very small, but it is still annoying.
Does anyone know why it happens and how it works.

There’s a tiny contact offset for any physics shapes involving polygons. This is to keep contacts stable. It is not however 0.1 (10cm), it’ll be more like 0.01 (1cm).

The idea is that this isn’t noticable at the correct viewing scale (numerically significant, visibilty insignificant). You are free to make your renderers slightly larger or the colliders slightly smaller if you wish.

The physics engine (Box2D) has this hardwired however we modified that to allow you to change it but there are consequences to doing so, namely stability to if you change it and you don’t know what you’re doing then be aware.

Also, see “Polygon Skin” here: Box2D: Collision Module

1 Like

Oh I know that it is not 0.1,
I learnt it the hard way…
But thanks

Okay but you stated 0.1 above and didn’t update your post. So you’ve solved your issue?

0.1 is just an example, not the real value.

I’m discussing the separation between colliders, not the absolute position. Maybe we’re at cross-wires here.