How can I remove certain tiles from a scene in the script

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

I want to have it so that when the player moves into a certain position, specific tiles are removed to reveal a pathway.

I’ve heard about set_cell() but I’m not sure how to implement it into my code.
I tried:

if position = Vector2(20, 10):
 Tilemap.set_cell(26, 10 -1)

But it doesn’t seem to work
I’m obviously new to Godot and would appreciate any help to teach me how to use set_cell()

Tilemap.set_cell(26, 10 -1) is setting a cell to -1, which is actually equal to TileMap.INVALID_CELL. So your code should work, it is effectively removing the tile at (26, 10), allowing to see whatever is behind (assuming you did put something behind?)

Zylann | 2020-03-10 02:04

:bust_in_silhouette: Reply From: Merlin1846

This should work.

func removeTile(position):

that will remove which ever tile is at “position”

you can also use “set_cellv()” if you want to use a non tilemap position such as the character position. Also you might want to check out the documentation for Tilemap documentation