Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you debug 3D raycasts?

Tags:

c#

godot

In Godot, if a 3D raycast isn't hitting where you'd expect it to hit, how do you debug it? I'm looking for some way to draw the ray (or a line that follows the ray), problem is, I can't find anything in the docs, so your help is much appreciated.

like image 527
SePröbläm Avatar asked Sep 28 '26 00:09

SePröbläm


1 Answers

Sadly there is no easy way to accomplish a "Line3D" in Godot (There are some free assets and third party solutions for that).

However, being for debug purposes, all you have to do is enable "Visible Collision Shapes" on the "Debug" menu.


A common use of RayCast is to do them from the Camera. In which case they probably look like a point. And if you are also updating them every frame, they would follow the camera continuing to look like a point.

In that case, I suggest to duplicate or stop updating the RayCast you want to inspect on a key press. Said another way: Check if the user pressed a key, and when they do, either duplicate or stop updating the RayCast. Then you can move around and see the RayCast from an angle where it does not look like a point.

like image 93
Theraot Avatar answered Sep 30 '26 13:09

Theraot