As a Roblox developer, it is currently too hard to diagnose if my code is casting raycasts in the correct direction and with the right length.
If Roblox is able to address this issue, it would improve my development experience because i’d be able to diagnose if my raycasts are working properly just by toggling on rendering of raycasts in the visualization options.
Additionally you could add the same functionality for shapecasts (as well as blockcasts and spherecasts).
A simple rendering of a few pixel thick line from ray origin following ray direction for the specified length would be very helpful.
This would be neat, but it would really only be useful visually for casts happening per frame. Otherwise, the visualization would pop in and out of existence instantly. Maybe there would be more config around this.
Strictly speaking Raycast visualization has nothing to do with rendering to appear in render options.
How that should be implemented?
Game can do tons of raycasts per frame, so engine needs to collect them all and show on next rendered frame Ok, good, but you barely will be happy seeing this since that would be a mess.
So most likely you want to see a single raycast.
Here’s a script for you, put it wherever you need it and call it when you need.
local function drawVector(position: Vector3, direction: Vector3)
local part = Instance.new("Part")
part.Anchored = true
part.CanTouch = false
part.CanCollide = false
part.CanQuery = false
part.Position = position
part.Size = Vector3.one * .1
local a0 = Instance.new("Attachment", part)
local a1 = Instance.new("Attachment", part)
a1.Position = direction
local beam = Instance.new("Beam")
beam.Attachment0 = a0
beam.Attachment1 = a1
beam.FaceCamera = true
beam.Width0 = 1
beam.Width1 = 0
beam.Parent = part
part.Parent = workspace
game:GetService("Debris"):AddItem(part, .1)
end
Imagine how much easier this is, instead of following your suggestion and putting more bloat into engine.
Don’t be grateful.
Thank you!
I agree, I havent thought about that as I am raycasting per-frame…
potentially the engine could leave a faint trail of a raycast for a few seconds (or as long as you set).
Alright @af_2048,
need I remind you in the guidlines for feature requests it says not to focus on how it would be implemented but why it should be implemented.
Please focus on use cases and problems. Do not focus your request around a proposed solution (i.e. API suggestion, or a specific technical way to solve an issue).
But regardless, yes, it would only be useful for visualizing specific raycasts - for example those originating from some specified bounding box or (and this would be even more useful in my opinion) those in the vicinity (some range) of a selected objects origin. I doubt this would be too expensive to implement as all raycasts already go through the WorldRoot (workspace).
And I dont see your point with it not having to do anything with rendering, it would be rendering of the rays. If you mean that raycasts themselves dont have anything to do with rendering then yes, but that would also apply to for example collision fidelity, constraints or pathfinding that you can visualize from render options.
By your logic all debuging tools are bloatware of the engine and should be left to the user to make all of them, I am not grateful as its hard for me to follow this logic of yours.
And to both you and @kingerman88, thank you for the code - I know its possible to code it as I have myself but it would be much much more convenient and quick if this was a render option.