Godot version:
3.1
OS/device including version:
Windows 10
Issue description:
Currently if you create a map layout using the tilemap (with associated tiles that have staticbody collisions) and decide you wanted to scale your 64x64 cell tile map down and use that as an instanced scene to fit inside some portion of your main scene it's impossible to get the correct collided tiles cell position w/out using some weird workaround because when you scale down the instanced node that contains multiple tilemap's it only takes into account the _actual_ size of the tilmap's cell size when you call world_to_map. Rather than it's scaled value from its parent node.
I've been told you could use a camera to solve this or recreate the whole tile in the _actual_ size tiles you want your tilemaps to display as in your instanced scene. Well I think that the fact that those same tilemap's can properly collide when scaled, but not properly get the world_to_map value based on it's scale value means there's an inconsistency with the api that you can't really work around out of the box.
Suggestion
My suggestion is to add an optional parameter or introduce a new method with a default scaling value of 1 (because this probably would break existing projects if you took into account the scaling of the tilemap's parents now) that way we can pass a custom float value so when we scale the parent of the instanced level, we can get an accurate representation of the location of a collided cell without having to apply weird camera workarounds or completely remaking our tilemap using smaller tiles.
I think what you want is to_global(map_to_world(X)) and world_to_map(to_local(X)).
world_to_map and map_to_world are probably badly-named, but they converts between tile coordinates (measured in an integer amount of tiles) and world coordinates (measured in real amount of pixels). They do not convert to global coordinates (measured in pixels again).
Ah yes, you're a genius. I had no idea to_local existed, which tilemap inherits from node2d.
I did the following:
var loc = node.WorldToMap(node.ToLocal(GlobalPosition)); // or Position
In my collision detection and it gets the location of my player's cell from which it collided with the tilemap. Even when scaled :O amazing. Going to close this for now.
Most helpful comment
I think what you want is
to_global(map_to_world(X))andworld_to_map(to_local(X)).world_to_mapandmap_to_worldare probably badly-named, but they converts between tile coordinates (measured in an integer amount of tiles) and world coordinates (measured in real amount of pixels). They do not convert to global coordinates (measured in pixels again).