0 votes


I have a scene with obstacles (StaticBody2D), a player and its companion (both KinematicBody2D).

I'm trying to have the companion not colliding with the obstacles, but it just won't. Even though I put them on different layers with non-overlapping collision masks :

Player : Layer = 1, Mask =3
Companion : Layer = 1, Mask = 1
Obstacle : Layer = 2, Mask = 0

Is there a way to do that ? Am I missing something obvious ? Or should I find another way around ?

(If it's any help, the player move through direct input and the companion follow him using a Navigation2D node that approximately coincides with the obstacles)

Thanks in advance for your help

in Engine by (19 points)

2 Answers

0 votes
Best answer

I finally solved the problem by using RigibBody2D in Kinematic mode for the companion, instead of KinematicBody2D. Behaves as expected so far.

by (19 points)
0 votes

Well, I think I know a solution, not through code but through the settings.

Every PhysicsBody has the property Collision in the Inspector. So with your node selected, go to the Inspector tab, go to PhysicsBody, click on Collision and you see several rows on Layer and Mask. A highlighted block on Layer is the layer the node is part of. A highlighted block in the Mask is on which layers it can collide with.

Hope that helps.

by (28 points)

Thanks for your answer !

Unfortunately, it's already what I tried. The companion and obstacles collide even though the obstacles are not on a layer that's part of the companion's mask, and vice versa. Sorry the question wasn't clear enough.

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 [email protected] with your username.