Can I detect contact between an Area2D and a TileMap tile with collisions enabled?

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

In my project I have a spell attack that uses an Area2D as the root node. I can detect when it enters kinematic bodies without problem so it can dissipate and affect players/enemies.

However, I have a TileMap that I am using to draw levels with floor and walls. The player and enemies collide with the walls, but I am struggling to find out how to make the spell dissipate upon touching the walls. I don’t want them to be able to go through walls.

Can I do this, or do I have to make the attacks use a kinematic body? The only problem with that is they physically interact with other bodies they collide with when I don’t want them to.

Area2D’s body_entered signal will fire on TileMaps too. Share more about your implementation and maybe we can see why it’s not working for you.

kidscancode | 2020-05-21 15:29

You are right, it works now- the problem was that the script was checking if the colliding body was an enemy and not considering tiles at all. I’ve changed it to collide with all bodies that aren’t the player.

artsyWraith7 | 2020-05-21 15:53

Now try to find the tile cell that collided though…

chucklepie | 2021-06-06 12:27

Detecting the tile you collided with is very easy:

kidscancode | 2021-06-06 16:35