0 votes

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? :)

Godot version 3.2.3
in Engine by (42 points)

1 Answer

0 votes

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
by (305 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.