How to detect collision with a tilemap?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MOSN

I have an area2D that’s supposed to print a message on body_entered(), it’s monitoring, it’s layer 4 and I have a tilemap with collision set to layer 4, and several tiles that have collision. As far as I can tell there are no monitoring of monitorable options for a tilemap.

Seems like it should work but it doesn’t. The body_enters() signal specifically states that it is emitted when a body or tilemap enters, so it should be possible. It says that the Tilemap is detected if the Tileset has collision Shape2Ds which I assume is just the regular collision you set up with “Collision Mode” for a Tileset.
I’ve also tested that everything else is set up correctly by setting the Area2D to a different mask with other objects and that works fine.

Not an answer but u can use raycasting for detecting collision on tilemaps

horsecar123 | 2022-03-31 21:15

Hmm, that might work for what I need as a backup plan, but yeah would still like to know how to do it with an Area2D.

MOSN | 2022-04-01 10:26

Still need help with this one if it’s possible and seems like a fairly major bug if it isn’t. Not sure if this bumps the topic or anything but figure it’s better to try first rather than repost.

MOSN | 2022-04-28 10:59

i guess you coulnt add collision to your tilemap(for me , signals can detect tilemaps without doing anything special ) , please check if its colliding with bodies

horsecar123 | 2022-04-28 12:40

Okay I found the issue after doing an extra round of testing and it’s not one that makes any sense. For some reason when it comes to Tilemaps both Monitoring and Monitorable have to be set to true for an area2D to be able to monitor them. It can register other objects just fine with only Monitoring enabled, but apparently not Tilemaps…
Oh well, whatever works.

MOSN | 2022-04-28 16:11