0 votes

I'm trying to set up two kinematicbody2ds such that objectB ignores objectA for collisions, but not vice-versa. I thought masks would let me do this, but no luck so far.

So I've seen other people say:

"Collision_layer describes the layers that the object appears in. Collision_mask 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."

I have a kinematicbody2D bullet. No layers, mask set to 1 (eventually I want the bullet to detect the player). No motion or scripting for now.
I have a kinematicbody2D arrow-key-controlled player using move_and_slide. Layer 1, mask 1.

Since the bullet has no layers, I would expect the player to not see any collisions when using move_and_slide - but I still do. Any idea what I'm doing wrong? If layers are the wrong way to do this, other suggestions would be appreciated.

in Engine by (12 points)
edited by

1 Answer

0 votes

If they bullet has no collision layers, it still might have a collision mask, likely with layer 1, so any objects that are a part of layer one will collide with the bullet.

The strategy to do one way collisions with a bullet that you want to move with moveandslide, is to have an area node as a child of the kinematic body that detects collisions with your objectA. The area node can detect a collision with the player, and the kinematic body can detect collisions with the floor.

by (388 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 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.