Godot Version
4.5.1
Question
I have created a map from multiple tilemaplayers as below, with tiles from 64x64 up to 256x256.
I have laid out the tiles to make roads, buildings and large areas, all viewed from above, with each tile being intended to be selectable in game to allow decisions to made regarding them (think management type game)
The complete map when viewed in game looks like below with the smallest tiles being 64x64
In effect I have each size of tiles on its own layer so I can lay them out in a city grid as viewed from above.
Individually they look like this
and so on.
My problem is trying to determine when I click on the map in-game, how do I detect which tile is selected across the 9 layers.
I attached a script to each tilemaplayer, with the following code
extends TileMapLayer # Or TileMap
func _input(event):
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed():
# Get the mouse position in the TileMap's local space
var local_mouse_pos = to_local(get_global_mouse_position())
# Convert local position to map (tile) coordinates
var tile_coords = local_to_map(local_mouse_pos)
print("Clicked on tile at map coordinates: ", tile_coords)
and each click when running, returns a different tile address for each layer it is attached to, with for example, the 256x256 tile returning 16 different possible coordinates for the same tile using the 64x64 script, but only 1 from the 256x256 script
How would I detect for example that the 64x64 tile was pressed, but in the same way detect when the 256x256 tile is pressed, and so on, across all the layers ?
I think I may have done something fundamentally wrong either with using so many layers, or attaching the script to each layer is maybe wrong, or maybe the whole approach ![]()
Any help is appreciated.



