Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | keidav |
How do I remove a tile from a scene programmatically? I have tried the following to no avail:
_physics_process(_delta):
...
velocity = move_and_slide(velocity, Vector2.UP)
for i in get_slide_count():
var collision = get_slide_collision(i)
if collision.collider.name == "MysteryBox":
remove_tile(collision.position)
func remove_tile(position):
var tilemap= get_parent().get_node("Tilesets/MysteryBox")
tilemap.set_cell(position.x, position.y, -1)
I can detect the MysteryBox when the player collides with it, but the remove function is not removing the tile the player touched from the scene. Thanks in advance!