world_to_map()
converts from global coordinates to tile coordinates. Say your tiles are 64x64 and KinematicCollision2D.position
gives you (322, 520). world_to_map(KinematicCollision2D.position
would return (5, 8)
- you're standing in tile (5, 8). If you need to know the tile below you, for example, would be (5, 9)
.
As I read your question, that's what you were looking for. If you need to know what tile you hit, TileMap.get_cellv(Vector2(5, 9))
is going to give you the ID of the tile in that position.