is it possible to let an area 2d collide with a tilemap

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

Hello, I am making a game. The player has the ability to shoot, I want the bullet to disappear after it hits a wall(my tilemap), so I placed both on the same collision layer and connected them with a signal when the bullet hits the wall it will disappear, however, it just goes through. How should I do this?

Thanks

Is the bullet a physics object? How are you moving it?

*** Edit ***

Oh, I see you’re title answers my main question…

jgodfrey | 2022-10-20 16:41

I am using an area 2d

GodotUser21 | 2022-10-21 02:37

:bust_in_silhouette: Reply From: jgodfrey

Yes, you can do this. Typically, you’d do something like:

  • Put the wall tiles on a specific layer (say 1)
  • Put the bullets on a specific layer (say 2)
  • Ensure the bullet’s Mask includes the wall layer (so, 1)
  • Wire the bullet’s body_enteredsignal to a script
  • When the signal fires, queue_free() the bullet
  • Season to taste… :slight_smile:

Ok thanks :slight_smile:

GodotUser21 | 2022-10-21 02:38