Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | quizzcode |
Hello !
So I have read that world_to_map isnt global and I have to use to_local for world_to_mapand and to_global for map_to_world.
But it changes nothing…
Here is my set up :
my project is phone size project. My elements are 3x bigger for scaling purpose.
So my main node is scaled X and Y to 0.389.
Everything works great, path finding of the unit on the map depending on the type of tile etc…
But, When I’m creating my build tool for elements to add on the map (based on tile positioning) turns out the info coming back from world_to_map (to local or to global) are as if my nav tile was not scaled to 0.389 but a full on 1.
I tried scaling down nav : nothing. tried scaling down timemap_nav : nothing.
I’m running out of ideas.
Here is a little video of how it’s looking like.
You can see that the tile aren’t matching the tile size (green and orange background), as if the world_to_map info was never scaled down to the project size
I read somewhere that someone found a “haccky fix” where they divide the return or world_to_map by the scale desired. But world_to_map returns me tile cords like 2,6 not cords…
Any idea ?
Here is my code :
var mouse_pos = get_global_mouse_position()
current_tile = map.world_to_map(to_local(mouse_pos))
var id_tile = map.get_cellv(current_tile)
$build_tool.global_position = map.map_to_world(to_global(current_tile))
(yes i have tried to invert the to_local and to_global, and also not using them.
here are my nodes
- playing (scaled 0.389)
nav >tilemap_nav
I’m sure it’s something simple… But I have bene on it since yesterday and I’m getting blind.
Thank for your time.
can i highlight that if you are using the scale property to scale everything to a “phone screen” size, you could simply set the camera zoom instead?
Andrea | 2021-08-29 12:52