How do I detect a certain tile type clicked?

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

I want it to print the name of the tile, or at least its number, instead of its coordinates. How do I do that?

:bust_in_silhouette: Reply From: kidscancode

If you have the tile location,

var tile_pos = Vector2(4, 3)

get_cellv() tells you the tile id:

var id = get_cellv(tile_pos)

And once you know that, you can then pull information from the TileSet (map’stile_set property):

var tile_name = <tilemap_node>.tile_set.tile_get_name(id)

These methods can all be found in: