Disable collision with a specific object

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

I’m trying to make my character to drop through a platform (like Castlevania SotN). The way that I was trying to do it was disabling the collision of the platform. But of course that if do it, it will disable the collision of this platform with all other objects(including enemies in this platform).

Is it possible to only disable the collision of an CollisionShape2D with an specific object, instead of disabling all collisions?

Thanks in advance ^^’

:bust_in_silhouette: Reply From: kidscancode

Collision layers are designed for exactly this. See this link for an overview:

Thank you! ^^
It is a really good solution. But I solved my problem by using add_exception_with(obj), that KinematicBody2D inherits from PhysicsBody2D!

rless | 2019-01-16 15:24

Thank you for your comment, @rless - it was just what I was looking for. I am using layers and masks, but sometimes you just need something more granular. For example: a car shouldn’t collide with its driver but should collide with everyone else, even his allies.

oskfo | 2019-08-10 15:41