TileMap appears to set the wrong tile.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CollinOmmen

I have a TileMap with the origin at the top left of the screen. The goal is to have a tile fill green from white when selected. However when I select a tile, the tile above it, position (x, y-1), is filled instead. This can be patched with a simple offset to the y coordinate, though I’m worried that I might be overlooking a mistake that could later rear its head.

I have tried both set_cell and set_cellv, but they yield the same result. Though, when I print out the position of the cell, it shows to be correct.

The commented line below is the offset that can be applied to patch the issue.

extends TileMap

func _unhandled_input(event):
	if event is InputEventMouseButton:
		if event.button_index == BUTTON_LEFT and not event.pressed:
			var cell_position = world_to_map(event.position)
			print(cell_position)
			# cell_position = Vector2(cell_position.x, cell_position.y + 1)
			if get_cellv(cell_position) != INVALID_CELL:
				set_cellv(cell_position, 1)

Am I using this class and function as I should for my expectations? Or could there be an underlying issue?