Composite Collider Bug: Assertion failed on expression: 'ValidTRS()'

This appears to be a bug to me, but maybe someone can let me know if something is wrong that I’m missing.

When my player runs into a tilemap tile that they can destroy, then this error will happen only on the first collision:

Assertion failed on expression: ‘ValidTRS()’

private void OnCollisionEnter2D(Collision2D collision)
{
    
    if (collision.collider.CompareTag("CollisionTilemap"))
    {
        Vector3 contactPoint = collision.contacts[0].point;
        Vector3Int tilePosition = collisionTilemap.WorldToCell(contactPoint);

        TileBase tile = collisionTilemap.GetTile(tilePosition);

        if (tile != null)
        {
            collisionTilemap.SetTile(tilePosition, null);
        }
        else
        {
            Debug.Log("No tile found at position: " + tilePosition);
        }
    }
}

This only happens when colliding with the composite collider on the tilemap.

ValidTRS comes from Matrix4x4 or the Tile system not the CompositeCollider2D. It means a Transform Matrix4x4 was invalid, possible NaNs etc.

You’ve made the leap that because it happens after a collision with a specific collider type but that doesn’t mean it’s anything to do with that so look at the callstack as it’ll show you where it’s coming from rather than when you think it’s happening. It could be that its the code you posted which has a bad tile position when it sets the tile transform.

Yes, because it’s only when you collide with that specific collider do you execute your code. It doesn’t mean it’s anything specifically to do with the composite unless you have a callstack that’s saying that. :slight_smile:

The callstack should show you the originating call site that triggers the issue. Also, attach a debugger to the place and look at what you’re receiving and sending back from/to Unity.