unity config_error ai_generated true

ArgumentException: TilemapCollider2D: Invalid bounds. The tilemap bounds are empty.

ID: unity/tilemap-collider-invalid-bounds

Also available as: JSON · Markdown · 中文
90%Fix Rate
85%Confidence
1Evidence
2023-09-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Unity 2022.3.5f1 active
Unity 2023.2.0b2 active

Root Cause

A TilemapCollider2D component is added to a Tilemap that has no tiles placed, causing the collider to compute empty bounds.

generic

中文

TilemapCollider2D 组件添加到了没有放置任何瓦片的瓦片地图上,导致碰撞体计算出空边界。

Official Documentation

https://docs.unity3d.com/Manual/class-TilemapCollider2D.html

Workarounds

  1. 95% success Add at least one tile to the Tilemap using the Tile Palette or script: `tilemap.SetTile(new Vector3Int(0, 0, 0), yourTile);`.
    Add at least one tile to the Tilemap using the Tile Palette or script: `tilemap.SetTile(new Vector3Int(0, 0, 0), yourTile);`.
  2. 90% success Remove the TilemapCollider2D component if the tilemap is meant to be empty, or use a CompositeCollider2D with a separate collider setup.
    Remove the TilemapCollider2D component if the tilemap is meant to be empty, or use a CompositeCollider2D with a separate collider setup.

中文步骤

  1. 使用瓦片调色板或脚本在瓦片地图上至少放置一个瓦片:`tilemap.SetTile(new Vector3Int(0, 0, 0), yourTile);`。
  2. 如果瓦片地图应为空,则移除 TilemapCollider2D 组件,或使用 CompositeCollider2D 配合独立的碰撞体设置。

Dead Ends

Common approaches that don't work:

  1. 80% fail

    Disabling and re-enabling the collider does not fix the empty bounds; the collider still has no tiles to compute from.

  2. 90% fail

    Setting the Tilemap's cell size to zero or negative values may cause other errors but not resolve the empty bounds.