0 votes

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.

asked Dec 23, 2019 in Engine by rogerdv (84 points)

1 Answer

0 votes

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.
answered Dec 23, 2019 by kidscancode (13,384 points)

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

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: http://kidscancode.org/godot_recipes/2d/tilemap_collision/

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.