8/11/2025

How to Make Your Tilemap Clickable in Godot

Hey everyone, so you're diving into Godot & you've got this awesome tilemap set up. It looks great, but it's just... static. You want to click on tiles, make things happen, maybe build a city, select a unit, or have a farmer plant some crops. Honestly, making your tilemap interactive is one of the most common hurdles for new & even experienced Godot developers. Turns out, there are a bunch of ways to tackle this, each with its own pros & cons.
I've spent a good chunk of time wrestling with this myself, so I figured I'd put together a pretty extensive guide on how to get it done. We'll start with the basics & then move into some more advanced, specialized techniques. By the end of this, you'll be able to handle just about any kind of tilemap interaction you can dream up.

The Foundation: Getting Mouse Clicks & Tile Coordinates

Before we do anything fancy, we need to handle the absolute basics: detecting a mouse click & figuring out which tile you clicked on. This is the bedrock of any clickable tilemap system.
First things first, you'll want to set up an input action. This is WAY better than hardcoding mouse buttons directly in your script. It gives you more flexibility later on.
  1. Go to Project -> Project Settings.
  2. Click on the Input Map tab.
  3. In the "Add New Action" box, type something like
    1 click
    & hit "Add".
  4. Click the little "+" icon next to your new
    1 click
    action, select "Mouse Button", & then choose "Left Button" from the dropdown.
Pretty cool, right? Now, in any script, you can just check for the
1 click
action.
Let's create a script & attach it to your
1 TileMap
node or a parent node that has the
1 TileMap
as a child. Here's the basic code to get the tile coordinates from a mouse click:

Copyright © Arsturn 2025