Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | ShinRamen |
func _process(_delta):
var mousetile = GameManager.tilemap.world_to_map(get_global_mouse_position())
var localPosition = GameManager.tilemap.map_to_world(mousetile)
var worldPosition = GameManager.tilemap.to_global(localPosition)
global_position = worldPosition
that is what i have at the moment, i am very new to scripting so i would appreciate any advice.
I also keep getting the ‘Nonexistent function ‘world_to_map’ in base ‘Tilemap’’ error. thank you
In godot 4:
- TileMap’s
world_to_map()
is nowlocal_to_map()
. - TileMap’s
map_to_world()
is nowmap_to_local()
.
Give those a try and see how you get on. These docs may also help:
TileMap — Godot Engine (stable) documentation in English
Upgrading from Godot 3 to Godot 4 — Godot Engine (stable) documentation in English
spaceyjase | 2023-05-31 13:03
Thank you! This has been the issue, I appreciate your help!!
ShinRamen | 2023-05-31 13:15
I’d recommend that someone copy @spaceyjase’s answer as an actual Answer. That way, the question will show as having been answered on the main Q&A page, which is helpful for people searching for an answer to a similar problem in the future.
jgodfrey | 2023-05-31 14:37