Calculate the global position of the corner of a tile

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Hammo

Is it possible to calculate the global position of the corner of a tile in a TileMap?

Corner of the TileMap

hey, it would be nice to know if my awnser did or did not help you!

Pomelo | 2022-06-23 12:04

:bust_in_silhouette: Reply From: Pomelo

I suggest you read the Documentation. It solves your question and more that could arise. This is exactly taken from the docs in the map_to_world method: “Returns the local position of the top left corner of the cell corresponding to the given tilemap (grid-based) coordinates. To get the global position, use Node2D.toglobal

In summary use map_to_world(Vector(x,y)) (you need to pass it the tiles coordinates in a Vector2) to get the local position, and then use to_global(your_local_position) to transform it into the global position.