How to get atlas coor in TileSet from a position in a TileMap in Godot 4 (code inside)

Godot 4.2.2

I’ve used the editor to place the tile at atlas coordinates (0,3) from tileset 15 on a tilemap at position (12,0) in layer 0.

I need to query position (12,0) in the tilemap and get the tile’s atlas coordinates (0,3).

I’ve tried the following:

print(Map.get_cell_source_id( 0, Vector2i(12,0) ))
-> 15
print(Map.get_cell_tile_data( 0, Vector2i(12,0) ))
-> <TileData#37715182896>
print(Map.get_cell_tile_data( 0, Vector2i(12,0) ).get_property_list())
-> [ { "name": TileData, "class_name": &"", "type": 0, "hint": 0, "hint_string": TileData, "usage": 128 },
{ "name": Rendering, "class_name": &"", "type": 0, "hint": 0, "hint_string": "", "usage": 64 },
{ "name": flip_h, "class_name": &"", "type": 1, "hint": 0, "hint_string": "", "usage": 6 },
{ "name": flip_v, "class_name": &"", "type": 1, "hint": 0, "hint_string": "", "usage": 6 },
{ "name": transpose, "class_name": &"", "type": 1, "hint": 0, "hint_string": "", "usage": 6 },
{ "name": texture_origin, "class_name": &"", "type": 6, "hint": 0, "hint_string": suffix:px, "usage": 6 },
{ "name": modulate, "class_name": &"", "type": 20, "hint": 0, "hint_string": "", "usage": 6 },
{ "name": material, "class_name": &"CanvasItemMaterial,ShaderMaterial", "type": 24, "hint": 17, "hint_string": CanvasItemMaterial,ShaderMaterial, "usage": 6 },
{ "name": z_index, "class_name": &"", "type": 2, "hint": 0, "hint_string": "", "usage": 6 },
{ "name": y_sort_origin, "class_name": &"", "type": 2, "hint": 0, "hint_string": "", "usage": 6 },
{ "name": Terrains, "class_name": &"", "type": 0, "hint": 0, "hint_string": "", "usage": 64 },
{ "name": terrain_set, "class_name": &"", "type": 2, "hint": 0, "hint_string": "", "usage": 6 },
{ "name": terrain, "class_name": &"", "type": 2, "hint": 0, "hint_string": "", "usage": 6 },
{ "name": Miscellaneous, "class_name": &"", "type": 0, "hint": 0, "hint_string": "", "usage": 64 },
{ "name": probability, "class_name": &"", "type": 3, "hint": 0, "hint_string": "", "usage": 6 },
{ "name": Rendering, "class_name": &"", "type": 0, "hint": 0, "hint_string": "", "usage": 64 },
{ "name": Physics, "class_name": &"", "type": 0, "hint": 0, "hint_string": "", "usage": 64 },
{ "name": Navigation, "class_name": &"", "type": 0, "hint": 0, "hint_string": "", "usage": 64 },
{ "name": Custom Data, "class_name": &"", "type": 0, "hint": 0, "hint_string": custom_data_, "usage": 64 },
{ "name": script, "class_name": &"Script", "type": 24, "hint": 17, "hint_string": Script, "usage": 1048582 } ]

I’m going nuts. Apologies if the question is somehow self-evident but I’ve searched the docs, the forum, the webs,…

Thank you all.

TileMap.get_cell_atlas_coords()

1 Like

You are my favorite person of the day.