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.
Pretty cool, right? Now, in any script, you can just check for the
action.
Let's create a script & attach it to your
node or a parent node that has the
as a child. Here's the basic code to get the tile coordinates from a mouse click: