Yuval Amir
Yuval Amir

Reputation: 203

The collider generated by tilemap collider 2d is slightly too big

When I use tilemap collider 2d the collider is too big. I attached a picture showing the bug with 2 squares with a box collider 2d and rigidbody 2d falling on the tilemap, without touching it.

The bug

edit: StackOverflow doesn't let me change the tag I put on accident (from unity3d to unity2d) and after I deleted the post and tried reposting with the right tag it doesn't let me post the corrected version because its a mirror of this one so sorry...

Upvotes: 1

Views: 1325

Answers (1)

Harshdeep Singh
Harshdeep Singh

Reputation: 315

Try lowering Default Contact Offset. You can edit it under Project Settings > Physics2D.

It essentially defines half of the minimum distance two colliders need to be from each other to register as colliding.

Set a proximity distance value for colliders to be considered in contact, even they are not actually in contact. Colliders whose distance is less than the sum of their contactOffset values generate contacts. This allows the collision detection system to predictively enforce the contact constraint even when the objects are slightly separated.

Upvotes: 1

Related Questions