How can i get a TileID From X and Y coordinates

I posted a question few months ago and actually dropped the idea but now picked it up again i am almost done with the solution but i cant seem to figure out how i can get the TileID of some tileset’s Tile Via X and Y coordinates can anyone please help me with this?
basically if i have Some Coordinates like 4 and 4 how can i get the specific Tile ID on the tile on that coordinate? i cant seem to figure out Maths for that
I hope my question was clear


Y*W+ X, where W is the width of the tileset (in tiles), X and Y the coordinates of the tile (in tiles). If your x and y are in pixels, you can obtain X and Y from them by dividing by the tile size:
X = floor(x / tileWidth)
Y = floor(y / tileHeight)

Naturally, this only applies to grid-based tilesheets, and not to Image Collections.

1 Like

It worked flawlessly,
Thank you for your help