Area2d can't reliably detect tiles added with TileMapLayer.set_cell()?

Godot Version

4.5.1

Question

I’m drawing tiles on a TileMapLayer at runtime, based on a Timer, using the set_cell() method. Tiles are showing up, I added an Area2D “detector” on the player(CharacterBody2D) and it can detect the tiles and I have the player smashing through them and removing them on collision. All works the way I would expect.

I have stationary objectives that need to be protected from the creeping tiles (Node2D), I put the same Area2D "detector” set up as on the player into these objectives. They cannot detect the tiles when added with set_cell(). They can detect everything else I could think to try: the mouse, the player, the player’s Area2D, the player on every other physics layer including the layer the tile collision shapes are using. They can detect the tiles themselves IFF I draw them in the editor to be overlapping. When they’re drawn at runtime using set_cell(), they are invisible to the objective’s detector Area2D but not the Player’s.

Has anyone else run into this? I’ve run out of ideas for what to try to fix it, and an hour of searching for every way I could describe it hasn’t led me to any answers. Happy to provide any code or screen shots needed, I didn’t provide any here because as far as I can tell I have two identical Area2D’s as children of two different parents and one setup works and the other doesn’t.

Thanks for your help :slight_smile:

Static Area2D won’t detect collision shapes created at runtime which the TileMapLayer does. There’s a note about it in the Area2D documentation:

Note: Areas and bodies created with PhysicsServer2D might not interact as expected with Area2Ds, and might not emit signals or track objects correctly.

You can toggle Area2D.monitoring off and on after updating the TileMapLayer to force the Area2D to update.

Thank you!!! I don’t know why my brain didn’t put together that was the problem from reading the docs, but that was absolutely the issue. Thank you for being a second pair of much needed eyes :grin: