RayCast2D doesn't collide

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By fedeb95
:warning: Old Version Published before Godot 3 was released.

Hi, I’m tackling my first Godot project, I searched every Q&A and documentation I found about the topic but I’m still not able to successfully make a raycast.

I’ve got a scene with a TileMap object and another one with a Sprite and four RayCast2D child nodes. The raycast are enabled, and I’ve set TileMap collision layer to 2 (checking the second little box in the gui) and RayCast2D’s layer_mask to 2 (checking second box). The Sprite collision layer is 1, and collision mask 2 (I’ve got other objects that must collide with the Sprite but not the raycast, that have collision layer 1).
In the _fixed_process() of my Sprite I check active_rc.is_colliding(), active_rc holding a reference to a RayCast2D. This never becomes true, i.e. print(active_rc.is_colliding()) keeps printing False. I read that if collision mask matches layer mask the objects collide, but for raycast only layer matters.

How do I make the method is_colliding() return True when the raycast collides with the tilemap (and nothing else), or what’s the proper way of obtaining the desired behaviour? I’d like to use GUI nodes and not cast the ray from code.

Thank you

:bust_in_silhouette: Reply From: jarlowrey

It sounds like your mask and layers are correct. Are you using Godot 3? In 3.0 it’s _physics_process, not _fixed_process