Detection of individual tilemap's tiles with an area2d!

extends Node2D

@export var area: Area2D
@export var map: TileMap

func _ready():
	area.body_shape_entered.connect(area_entered)

func area_entered(_body_rid: RID, _body: Node2D, _body_shape_index: int, _local_shape_index: int):
	map.erase_cell(0,map.get_coords_for_body_rid(_body_rid))

I found this here:

P.S.
For this you must set collisions to your tiles in tileset editor.

1 Like

Hi there, thanks for posting a tip!

You can put the code between ``` lines like this:

```gdscript
func _ready():
    print("hello world")
```

That will correctly format the code in the forum, so it looks like this:

func _ready():
    print("hello world")
2 Likes