Remove tiles at runtime

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rogerdv

Is it possible to remove tiles during runtime? I need to destroy some walls parts in a game, which is an ideal candidate to use tilemaps, but Im concerned that I cant selectively destroy elements.

:bust_in_silhouette: Reply From: kidscancode

The TileMap docs have you covered:

void set_cell ( int x, int y, int tile, bool flip_x=false, bool flip_y=false, bool transpose=false, Vector2 autotile_coord=Vector2( 0, 0 ) )

Sets the tile index for the cell given by a Vector2.

An index of -1 clears the cell.

Do they have some sort of collider to let me identify individual collisions?

rogerdv | 2019-12-23 18:02

The whole point of a TileMap is that individual textures and colliders are batched into a single object for performance. That said, when you collide with the TileMap, you can then use the collision position to determine which particular tile you collided with.

See here for a deeper explanation:

kidscancode | 2019-12-23 19:07