Is my understanding of layers/masks in physics wrong?

KaranvaKaranva Posts: 1Member

Hello,

I am working on a project in which I am using 3 layers/masks:

  • player: layer 1, mask 2,3
  • object (Area2D): layer 2, mask 1
  • hazard (StaticBody2D): layer 3, mask 1

And my understanding with that setting is that objects and hazards would not interact with each other, however on a hazard scene I have set up the Node: 'body_entered' in which I'm just printing the class of the body (body.get_class) and to my surprise it prints an object (layer 2) class.

So now I'm confused, and the documentation says: "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." Which would suggest that my original understanding is right, and yet it is not working like that when I try it out?


Tags :

Answers

  • kryzmakkryzmak Posts: 108Member
    edited February 12

    Yes, you are correct but as far as I know body_entered() does not check any layers or masks, just if a PhysicsBody has entered.
    As the documentation says, masks and layers are checked for collisions with intersect_ray()

  • SchusterSchuster Posts: 362Member

    Why do not you just use print(body.name)?

Sign In or Register to comment.