godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.06k stars 65 forks source link

Add "Debug color" to Raycast2D (like CollisionShape2D) #9757

Open inhalt120g opened 2 weeks ago

inhalt120g commented 2 weeks ago

Describe the project you are working on

A 2D arcade game whose characters rely heavily on RayCast2D for interactions with the environment.

Describe the problem or limitation you are having in your project

In my project I'm using various Raycast2D for detecting Area2Ds. More complex scenes have a few of these RayCast2Ds, so it can get confusing to distinguish these RayCast2Ds when (due to the complexity of a scene) some of them are turned off, then there are a few that are overlapping, then there are a few that are can look similar when zoomed out but are in fact different and so on.

When I have to adjust these, I usually first find the RayCast2D I have to adjust, turn its visibility on and off a few times, pay attention and remember which one starts blinking on screen and then proceed to adjust it. This is a bit tedious.

Admittedly the color of the RayCast2Ds can be somewhat adjusted using "Visibility / Modulate", but this is quite limited because the color of RayCast2D is pre set so the range of modification is very narrow (for example Alpha can only go down).

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Same like CollisionShape2D has "Debug Color", I think RayCast2D should also have such property. It'd help visually distinguish and organize RayCast2Ds when there are a few of them close to each other.

Adding this property to RayCast2D would also be more consistent with already existing design of other elements (for example other shapes, or SeparationRayShape2D which looks visually identical).

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Under the currently listed Properties in the Inspector, (for example under "Collide With") there can be a color picker just like in other such situations: image

If this enhancement will not be used often, can it be worked around with a few lines of script?

I don't know.

Is there a reason why this should be core and not an add-on in the asset library?

image

AThousandShips commented 2 weeks ago

See also:

inhalt120g commented 2 weeks ago

Reading the comments in #906, this one specifically by @KoBeWi : https://github.com/godotengine/godot-proposals/issues/906#issuecomment-791565621 (using modulate instead of adding a new property)

sounds to me like a better idea than what I originally proposed here. I see the suggestion didn't catch on in that thread but as far as I'm concerned I'd be perfectly happy to use Modulate to decide the color of RayCasts2D.

For this to work, the color of a RayCast2D would have to use Modulate property as a basis, right now using Modulate can't, for example, produce a clean white RayCast2D. And then other shapes would have to use this system too to make it consistent.