0 votes

Get the very first body encountered by RayCast in Godot? The nearest body? I have RayCast connected to the camera and I want to get the body on which the camera is pointed. I don't want to use 3D-click, because I want to have a specific distance at which I can click.

Godot version 3.5.1
in Engine by (79 points)

Maybe check for when the RayCast is colliding (via is_colliding() in the_physics_process() function) and then use the get_collider() function to get the first object which is colliding? is_colliding() will return true on the first frame it detects a collision.

Please log in or register to answer this question.

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.