Area2D's "area_entered" does collide with the wrong layers

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

I’m building a small 2D Top-Down Space Shooter game.

I have a Player, the PlayerShot and an Asteroid.
I setup the layers this way:
Layer1 = Static
Layer2 = Player
Layer3 = PlayerShot
Layer4 = Enemy
Layer5 = Asteroid

I setup the collision this way:

  • Label: 2 [Player]
  • Mask: 4, 5 [Enemy, Asteroid]


  • Label: 3 [PlayerShot]
  • Mask: 5 [Asteroid]


  • Label: 5 [Asteroid]
  • Mask: 3 [PlayerShot]

What i want is that the Asteroid gives sends a signal if it is hit by the PlayerShot, what it does. But it also gives out that signal if it gets hit by the Player.

I could remove the Layer “Asteroid” from the Player’s Mask, but then I won’t get a signal from the Player, if he crashes into an Asteroid

Could you please help me? :slight_smile:

:bust_in_silhouette: Reply From: Tato64

Not the best practice but…

Try using a group in the playershot node so:

if area.is_in_group("playershot")
    do stuff
    dont do stuff