The TilemapCollider component automatically generates collision shapes for tilemap edges.
When composite is FALSE, it creates individual rectangle colliders for each edge tile.
When composite is TRUE, it optimizes by generating connected line segments that follow the tilemap's outer edges.
This is useful for efficiently handling collision detection with tilemap boundaries.
Limitations: The collider shapes are generated once and cannot be modified after creation. To update the collision shapes, you must create a new TilemapCollider instance.

const tilemapCollider = new TilemapCollider({
composite: true,
offset: new Vector2(),
layer: "CollisionLayer",
physics: true,
ignoreCollisionsWithLayer: ["IgnoredLayer"]
});

Implements

Constructors

Properties

composite: boolean = true

Generate colliders that represent the outer lines of the tile map

ignoreCollisionsWithLayers: string[] = []

Ignores collisions with layers in the array

layer: string = ""

Collision layer

offset: Vector2 = ...

X-Y axis offset

physics: boolean = true

TRUE if this collider interact with rigid bodies