Godot: Add the ability to draw a line that shows intersect_ray()

Created on 9 Mar 2018  路  5Comments  路  Source: godotengine/godot

Godot version:
3.0.2 Stable

OS/device including version:
Windows 10

Issue description:
When checking the direct_space_state of a world for a collision using intersect_ray(), there is no way to actually see the ray being drawn without drawing it yourself in _draw(). It would be nice to include the drawing of the ray as part of the function. Drawing your own ray is prone to errors.

Steps to reproduce:
Use intersect_ray() to check for a collision. There's no way to see the ray that is being created, you have to draw a line that represents the ray.

archived feature proposal editor

Most helpful comment

Some sort of a debug suite allowing easy drawing of lines, boxes and spheres for debug purposes would be very welcome (Unity and UE4 users are definitely used to those being built-in). Boxes and spheres can be done manually by using the built-in meshes in Godot 3, but lines can be very very tricky as @justinluk pointed out.

All 5 comments

One problem I see with this is, in a regular game, there might be too many raycasts and queries going on, and you won't be able to tell which ones are which (also taking into account the fact that you could have bugs in your queries).

That's why I've opted for a slightly different solution, which is to have a kind of Debug global which I can call from anywhere with the same cast parameters, with some graphics options. Then that singleton draws the things using either _draw or an immediate geometry. Another advantage of this is, I can make them persist for more than the current frame, or turn them on and off individually. So yeah, you can make mistakes writing your own debug logs/draws, but it's also a lot more flexible.

Maybe a middle ground would be to have a dev-only function before queries that tells "I want to see the next query ingame with that color and X other params"

Some sort of a debug suite allowing easy drawing of lines, boxes and spheres for debug purposes would be very welcome (Unity and UE4 users are definitely used to those being built-in). Boxes and spheres can be done manually by using the built-in meshes in Godot 3, but lines can be very very tricky as @justinluk pointed out.

@Zylann I like the idea of your middle ground solution. Being able to select which rays are drawn and which aren't would be quite handy and stop the screen from getting cluttered.

The days I waste so much time trying to figure out what the hell my damn rays are doing make me wish I was using Unity. I wish there was a draw parameter in intersect_ray, true or false.

Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine.

The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker.

If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance!

Was this page helpful?
0 / 5 - 0 ratings