Hi, with the code below I face a issue when clicking on the tile to place the objects, when clicked with the right mouse button on the tile the objects spawn on the above tile or below tile depending where I click on the tile.
I tried adding a offset to the y pos but the results vary?
The tilemap is also set to the isometric position, so maybe I am missing something.

`extends TileMap

const ground_layer = 0
const objects_layer = 1

const ground_tiles_atlas_id = 0
const ground_1_tile = Vector2i(0, 0)
const ground_2_tile = Vector2i(1, 0)

const wall_tile_atlas_id = 1
const wall_tile_atlas_coords = Vector2i(0, 0)

#const building_tile_atlas_id = 2
#const building_tile_atlas_coords = Vector2i(0, 0)
@export var horizontalSize : int = 16
@export var verticalSize : int = 32

#var cell_is_empty: bool = true

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

func _ready():

for i in range(0, horizontalSize):
		for j in range(0, verticalSize):
			set_cell(ground_layer, Vector2i(i, j), ground_tiles_atlas_id, ground_1_tile)
			
			#cellisempty here

func _input(event):
if(Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT)):
var mousePos = get_local_mouse_position()
var tileMapPos = local_to_map(mousePos)

	var data = get_cell_tile_data(ground_layer, tileMapPos)
	var coordsOfClickedTile = get_cell_atlas_coords(ground_layer, tileMapPos)
	print(tileMapPos)
	
	
else:
	if(Input.is_mouse_button_pressed(MOUSE_BUTTON_RIGHT)):
		#print(right mouse press)
		var mousePos = get_local_mouse_position()
		var tileMapPos = local_to_map(mousePos)
		
		var data = get_cell_tile_data(ground_layer, tileMapPos)
		var coordsOfClickedTile = get_cell_atlas_coords(ground_layer, tileMapPos)
		
		#var offset = 0.32
		#tileMapPos = Vector2(tileMapPos.x, tileMapPos.y + offset)
		#add wall if cell empty
		set_cell(objects_layer, tileMapPos, wall_tile_atlas_id, wall_tile_atlas_coords)

`

colonydemo2.zip
489kB

Heres the project if anyone can see the solution?

Hi,

That seems to be because your tiles top/bottom parts are not aligned with tilemap cells as you would expect.

You can see that tilemap cell is actually at the center of your ground tile and not at the top (I marked one tile with red color plane to clearly see where tilemap cell is, but Godot seems to also show that with orange lines):

If you put your tiles on tilemap it cause that on top of every ground block actually 4 different tilemap cells connects:

So in this case depending on position you click on your ground tile it will select either left, right, top or bottom tilemap cell. Since all your tiles are same size in this particular case you are always interested in placing your object tile above (red marked) cell (that will make visually object placed on the ground where you clicked).

In your case (with tiles of size 32x32 and with tilemap cell size as 32x16) if you add mousePos.y -= 8 before var tileMapPos = local_to_map(mousePos) then it should work as you expect.

Thankyou for your response, -= 8 works perfectly for placing the objects now : ]