How to detect any object from one specific collision layer?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Bugsbane
:warning: Old Version Published before Godot 3 was released.

Hi there,
I want to put everything that can hurt the player on one separate collision layer.

I’m having trouble finding any kind of tutorial to detect the difference between objects on one specific collision layerto detect the player getting hurtthough. Any ideas where to look?

:bust_in_silhouette: Reply From: eons

Look at the collision layer mask, a CollisionObject uses its mask to detect collisions with a layer, so, body with mask 1 will detect bodies in layer 1 and won’t notice bodies in another layer.

Except for KinematicBody (3D) which does not uses masks for the movement API, only layers (is a bug/not updated implementation of “move”) and areas may detect other areas if collision pair (layer-mask) match on any direction.


Sometimes you can put everything on the same layer and just filter by node group (depending on the complexity of interaction between the different elements).