0 votes

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

in Engine by (17 points)

1 Answer

0 votes

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

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