Deleting a tile via mouse click only works in the first time

ninjor1ninjor1 Posts: 1Member
edited December 2016 in 2D

so I'm working on a terraria clone (with the idea of having the ability to create vehicles and such).
Anyway, I'm able to click on a tile using :

if is_colliding():
    var hit_collider = get_collider()
    if hit_collider extends TileMap:
        var tilemap = hit_collider
        var hit_pos = get_collision_point()
        var tile_pos = tilemap.world_to_map(hit_pos)
Which works but when I delete the tile using:
tilemap.set_cellv(tile_pos, -1)

Subsequent clicks delete the wrong tiles (usually the top left first)
Almost like removing a tile messes up things and the tiles change order. Is there a way around this?

Sign In or Register to comment.