![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Timofey |
world_to_map work if scale == Vector2(1, 1), but its don’t work if scale != Vector2(1, 1)
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Timofey |
world_to_map work if scale == Vector2(1, 1), but its don’t work if scale != Vector2(1, 1)
![]() |
Reply From: | Zylann |
Hard to know what’s wrong without seeing your code, but my guess is you are passing a world position to world_to_map
.
I regret to inform you this method doesn’t expect a true “world-space” position. Instead it expects a position local to the tilemap. If the tilemap is moved, scaled or rotated, you have to first convert your position to local space, and only then, you can call world_to_map
:
var tile_pos = tilemap.world_to_map(tilemap.to_local(world_position))
Check the documentation: TileMap — Godot Engine (stable) documentation in English