@Geffrey said:
It didn't work. When I click the middle chunk it only deletes tiles from the left chunk.
Hmm, I probably wrote the code for detecting the mouse wrong. I always have trouble writing stuff like that from memory.
Maybe this code will work?
func _process(delta):
if (Input.is_action_pressed(“ui_mouseleft”):
# Apparently this will get the mouse position local to this node. This means
# in theory we just need to check to see if it's within a range of 0 to the width of the chunk.
var local_mouse_position = get_local_mouse_position()
if (local_mouse_position.x > 0 and local_mouse_position.x < chunk_width * block_width):
if (local_mouse_position.y > 0 and local_mouse_position.y < chunk_width * block_depth):
var tile_at_mouse = $TileMap.world_to_map(get_global_mouse_position)
$TileMap.set_cellv(tile_at_mouse, -1)
But I don't know if that will work either. It is basically the same as the old code, just using the local coordinates instead of the global so it is a little easier to calculate with bounds.
If possible and you don't mind, could you send me a link to the project? That way I could better debug the problem and test things. That said, I totally understand if you don't want to and/or cannot share the project. It would just make it a tad easier to test things.
Btw, I should have mentioned the input code in any organization doesn't do anything when I click the left and right chunks. it only deletes chunks from all 3 when I click the center chunk, or with the code you presented, only the left chunk gets changed when I click the center.!
Interesting. So only the middle chunk was working with the previous/original code? And if I understand correctly, with the code I posted earlier when the middle chunk is clicked, the left chunk is effected? That is strange, maybe something else is causing the issue then.
Did you try testing 4 chunks or 2 chunks? I don't know if it would reveal anything, but maybe it would lead to what is causing the problem. Also, what does the node tree look like? Maybe all of the chunks except the middle chunk are accessing the wrong nodes or something.