How do you make tiles interactive in Godot?

Relying on the atlas coordinates for custom data might not be a good idea. If you want to make other tiles interactive, you will need to add again the coordinates somewhere and that won’t scale up.

I had to deal with your use case, and I have a better solution for you !

You could try to assign custom data to your TileSet’s tiles. Take a look at this part of the TileSet official documentation :

You could try the followings :

  • In the TileSet inspector (right of the editor window when you are inspecting the TileMap node, or the TileSet resource), add a custom data layer named “interactive” and set its type to bool
  • Go to the TileSet editor (you have it opened at the bottom on your screenshot) and go to the “Paint” section (“Zeichnen” in your language)
  • Select your custom data (“interactive”) in the “Paint Properties”, set it to true , and paint the tiles that you want to be interactive

Now for the scripting part :

  • Get the tile data with var tile_data := tilemap.get_cell_tile_data(0, your_tile_coords). It will return a TileData (see doc here)
  • For safety, you could check if get_cell_tile_data returned null : that can happen if the cell doesn’t exist
  • Check if the tile is interactive by using tile_data.get_custom_data("interactive") : if all goes well, you should be done
3 Likes