TileMap dont track my mouse

Godot Version

4.2.1

Question

Why tile dont track my mouse or i setting wrong?

`extends TileMap

var GridSize = 8
var Dic = {}

Called when the node enters the scene tree for the first time.

func _ready():

var colorrigth =0
for x in GridSize:
	for y in GridSize:
		Dic[str(Vector2(x, y))] = {
				"Type": "Board"
		}
		if y%2 == colorrigth:
			set_cell(0, Vector2(x, y), 1, Vector2(0,0), 0)
		else: 
			set_cell(0, Vector2(x, y), 0, Vector2(0,0), 0)
	if colorrigth==0:
		colorrigth=1
	else: colorrigth=0
print(Dic)

Called every frame. ‘delta’ is the elapsed time since the previous frame.

func _process(delta):
var tile = local_to_map(get_global_mouse_position())

for x in GridSize:
	for y in GridSize:
		erase_cell(1, Vector2(x, y))

if Dic.has(str(tile)):
	set_cell(1, tile, 2, Vector2(0,0),  0)

`


image

change to:

var tile = local_to_map(to_local(get_global_mouse_position()))
1 Like