I am using Box collider2D on a GameObjets and its position is moving by code.
I am using OnCollisionEnter2D to detect the collision and stop the translation.
But it looks like the OnCollisionEnter2D event is triggered before the collision occurred and there is a gap between the 2 objects. The size of the object is 0.1 unit. Here a Gif that shows what happens :
Have you tried maybe adding a trigger object childed to the moving object, then check for the trigger on that object, that may allow you more control over the actual location of the trigger
Not 100% sure - but I’ve seen this mentioned multiple times in the forums. I believe this is what you get with the 2D physics engine.
Maybe there is a real fix via code bits, but I’ve heard some say scaling up the sprite to be a little bigger than the collider has also been a quick fix.