Godot Version
4.2.2
Question
How do I add unique data per tile in a tilemap. Im working on a game where you can break and place tiles and while placing is straightforward breaking them has been giving me an issue. Each block type in the game has a unique health so wood and stone dont take the same amount of hits to break. But I cant even figure out a way to store health without it effecting every tile of that type.
If anyone knows what to do, thanks.
Code for breaking blocks (Not working)
func _ready():
getGridPos()
player = get_parent()
tileGrid = player.get_parent().find_child("Walls")
for i in tileGrid.get_used_cells(0):
tileDataGrid[i] = 4
print(tileDataGrid.size())
func breakBlock():
var usedTool = player.selectedItem.relatedTool
var dataAtPos = tileGrid.get_cell_tile_data(0, gridPos)
var blockAtPos : Block
if (dataAtPos):
blockAtPos = dataAtPos.get_custom_data("BlockData")
var miningDmg = player.selectedItem.relatedTool.miningDmg
if (blockAtPos && miningDmg >= blockAtPos.minDmg && Input.is_action_just_pressed("Action")):
print(tileDataGrid.get(tileGrid.local_to_map(global_position)))