How to Make Objects not Collide with Eachother

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

Currently I’m trying to make it so that my Player node and my LightningBolt node don’t collide with each other, but still will collide with other objects like terrain, enemies etc. Unfortunately, I haven’t been successful and the LightningBolt and Player continue to collide with each other. Both nodes are KinematicBody2D and they both are using rectangular CollisionShape2D child nodes to define their collision. I’m setting the Player’s collision layer to bit 0 and the collision mask to 1 and 2, while the LightningBolt’s layer is bit 3 and the collision mask is 1 and 2. My understanding is that since the LightningBolt’s masks don’t match up with the Player’s layer, there should be no collision, right? Here’s some pictures of their layers/masks so you can see that (hopefully) it’s set up as I’m saying it is.

Here’s the Player’s Collision setup:
Player Collision

And Here’s the LightningBolt’s Collision setup:
LightningBolt Collision

According to the doc:

collision_layer
    This describes the layers that the object appears in. By default, all bodies are on layer 1.

collision_mask
    This describes what layers the body will scan for collisions. If an object isn’t in one of the mask layers, the body will ignore it. By default, all bodies scan layer 1.

So it looks like your two nodes really should ignore each other…
Could you share a minimal project reproducing the problem?

Zylann | 2019-04-26 12:57

I figured out the issue. Turns out I left some code in the script for LightningBolt that set bit 2 to true for the mask and layer . . . a dumb mistake, but at least it’s fixed. Thanks for the response!

SaucySells | 2019-04-26 16:13