1
\$\begingroup\$

I have a simple object with a Rigidbody 2D and a Box Collider 2d, that's supposed to fall and land on a tilemap with a static Rigidbody 2D and a Composite Collider 2D. However, it slightly hovers above, as seen in the below picture. I've tried fiddling with edge radius and other settings, however, it doesn't seem to work. The gap can be seen in both the scene view and the play mode, so it's not a rendering problem. Any ideas?

zoomed-up image

the whole scene

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

There are several ways to fix this:

1- Go to Project Setting and then Physics 2D and change the value of Default Contact Offset to something smaller

2- make the collider slightly smaller than the sprite

3- use an Edge Collider instead of a Box Collider

Personally, I would go with the second option as the other two have their own issues:

  • Edge collider doesn't call functions like OnCollisionEnter2D and that may become a problem for you
  • changing the value of Default Contact Offset may result in a "glitchy" gameplay (like when the player jumps and then collides with the ground)
\$\endgroup\$
2
  • \$\begingroup\$ this was perfect! these solution options are exactly what I was looking for. For now I'm going with a combination of the first 2 and its working great! \$\endgroup\$
    – Max Bailey
    Mar 25 at 5:23
  • \$\begingroup\$ @MaxBailey you're welcome! just remember about the issues I've mentioned \$\endgroup\$
    – Arian_ki
    Mar 25 at 10:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .