How to find out on which cell of TileMap the cursor is located

Godot Version 4.3 Beta 1


I would like to customize the interaction between the user and TileMap by using a cursor. For example remove a tile, place a tile, etc. However, I have not found any official information about translating mouse coordinates to grid system. I know I can do it manually, ie:


global_mouse_pos = gms;
coord.x = round_down(gms.x // tile_size)
coord.y = round_down(gms.y // tile_size)

But it seems to me that constantly getting coordinates in this way would cause unnecessary resource consumption.

Is there some built-in method to get mouse grid coordinates?


1 Like