Detect collisions with a pass-through-able object

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

I need a RigidBody2D to be able to detect a collision with another object that the RigidBody2D can pass through.

My first attempt with this was to use an Area2D node, but the RigidBody2D cannot detect a collision with it. My second though was to have a StaticBody2D with collision shapes that have is_trigger set to true, but since godot 3.0 that has been removed.

I have no other ideas as to how I’ll make this work without having an Area2D node detect the collision and somehow send that to the RigidBody2D.

:bust_in_silhouette: Reply From: Diet Estus

I never used a RigidBody2D before, but I think the following would work.

Just attach a RayCast2D (or Area2D) to the RidigBody2D, and set the RayCast2D (or Area2D) collision layer to the layer of the pass-through-able object.

That way, you can check if the RayCast2D (or Area2D) ever collides with the pass-through-able object, while still allowing the parent RigidBody2D to pass through it.