composite collider 2d doesn't really work

collider type: sprite(Tilemap SO)

I think this happens because the collision itself is bigger than the grid.

but if you have boxes bigger than the grid then they create fucked up collision. like:

where as when its alone its just a box.

Thanks. Yes, might be a bug. Did you scale the sprite after adding the CompositeCollider2D or that's the original sizes?

thats original size

The CompositeCollider2D knows nothing about tile-map or the details of the individual collider the physics geometry comes from i.e. BoxCollider2D, PolygonCollider2D or TileMapCollider2D and certainly doesn't understand or care about grid size etc. The geometry is provided by the colliders and it simply merges them.

Just looks like some logic bug during merging, potentially related to the colliders changing and the merging going wrong. If you could create a really simple reproduction case I can get it fixed ASAP.

easy enough. heres the sprites(from kenney's assets^^)

just import then into the project.
create a pallette from them
create the tilemap
draw some shapes as above.
on the layer add the components: tilemap 2d collider , composite collider.
change tilemap2d collider to be used by composite collider and make the rigidbody static.

you'll see all the composites are either non existant or bad
colliders are from the scriptable object that gets created when adding the sprites to the palette(sprite)

if my steps suck. then heres a video

1 Like

Just looks to me like the CompositeCollider2D isn't compositing at all. Try disabling/enabling the CompositeCollider2D or TileMapCollider2D component to see if that kicks it into action.

Very strange. I'll try my own tests here.

yeah, only composites sometimes. very odd xD

Did anyone find a solution?

The post you're referring to is from 2016. There are no active bug reports for CompositeCollider2D. If you have a problem then please discuss this on your own thread or produce a bug report.


Composite 2d not work if game object children rotation or scale

If you have a problem, please post a new thread. I don't follow what you mean here. The composite knows nothing about hierarchy of transform changes, it composes colliders so if they exist and are attached to the same Rigidbody2D as the composite and they have their use-composite checked then they will get merged. If you find an instance where this doesn't work then please submit a bug report and send me the case number.