Topic was automatically imported from the old Question2Answer platform.
Asked By
Help me please
Hi!
I have a TileMap node with 3 types of tiles (let them be a, b, c). When I click on the screen I want to change the tile on which I have clicked with another one. I don’t have any idea about it. Can anyone please help me. Thank you in advance!
var tilemap = $TileMap
var mouse :Vector2 = get_global_mouse_position()
var cell :Vector2 = tilemap.world_to_map(mouse)
var abc :int = tilemap.get_cellv(cell)
var new_abc :int = (abc + 1) % 3 # just an example plus 1 modules 3
tilemap.set_cellv(cell, new_abc)
Thanks!
But how will I change cell value?
Help me please | 2021-07-14 16:22
tilemap.set_cellv(cell, new_abc) … I’ve updated my answer … pleas mark answer a the answer if applicable
I’m assuming you’re asking how to find what value to input into the set_cell function to get the cell you want placed? You can look in the tileset editor for that information.