Quick answer: Confirm Erase Tile sets the cell to -1 (empty). If collision persists, check for a separate Solid object covering the area, or regenerate the pathfinding obstacle map.
A destructible tile platformer: shooting a tile erases it visually but the player still collides with the empty space. Erase set the cell to -1, yet something blocks movement.
Verify Tile Is Erased
Add a debug: Set text to Tilemap.TileAt(cell_x, cell_y). Should return -1 after erase. If a positive number, the erase didn’t happen — check the event sheet.
Separate Solid Overlay
Common pattern: tilemap for visuals + invisible solid object for collision. The solid persists even when the tile is erased. Two fixes:
- Remove the solid object covering the same cell. Pair their lifetimes.
- Use Tile-Behavior Solid attribute — collision comes from tile data, not separate object.
Tile Collision in Tileset Editor
Tileset editor → per tile: collision polygon. Mark each solid tile with one. Construct uses the polygon for solid collision per-cell.
After erase, the cell has no tile ID, so no polygon, so no collision. This is the “correct” setup.
Pathfinding Cache
Tilemap → Set tile (cx, cy) to -1
Pathfinding → Regenerate obstacle map
Pathfinding caches a grid. Regenerate after destruction so AI routes through.
Physics Behavior Caveat
If using Physics, tilemaps don’t auto-update body shapes on tile change. Need a custom event or use Solid-based collision instead of Physics for destructibles.
Verifying
Destroy a tile. Player walks through the empty space. AI navigates around / through correctly. No invisible obstacles.
“Erase Tile is visual + collision when collision comes from tile data. If you have a separate solid, remove it in tandem.”
For complex destructible worlds, profile pathfinding regen cost. Bake obstacle map per region rather than globally if the world is huge.