Hello everyone,
right now i am trying to learn godot and following this tutorial:
So i set up a tile map, included in my scene and now in want to make a build preview. This preview also informs the player wether the current position is valid to build or not. But it seems that the tiles are offset in the y-Axis. Here a few pictures for clarification:
(red tower = cant build there; green = valid build pos)
Heres the code i am using to detect collision with the "TowerExclusion"-Layer
func update_tower_preview() -> void:
var mouse_pos = get_global_mouse_position()
var current_tile = map_node.get_node("TowerExclusion").world_to_map(mouse_pos)
var tile_pos = map_node.get_node("TowerExclusion").map_to_world(current_tile)
if map_node.get_node("TowerExclusion").get_cellv(current_tile) == -1:
get_node("UI").update_tower_preview(tile_pos, "ad54ff3c")
build_valid = true
build_location = tile_pos
else:
get_node("UI").update_tower_preview(tile_pos, "adff4545")
build_valid = false