I’ve noticed that ~1/50 raycasts just pretend that objects don’t exist.
I’ve tried shapecasts, they also suffer the problem.
No matter what I try, I cannot have raycasts consistently detect walls. I can reduce the amount of times they just pass through walls, but when I perform a large amount of raycasts, some of them ALWAYS miss. This is a huge problem, and I can’t find anybody else talking about it, or any potential solutions.
I used this code to verify the problem i’m having, it might be something i’m doing?
local part:BasePart = Instance.new("Part")
part.Position = Vector3.new(0,-100,0)
part.Anchored = true
part.CanQuery = false
part.CanTouch = false
part.EnableFluidForces = false
part.CanCollide = false
part.Color = Color3.fromRGB(255,0,0)
function CreateVisualRayPart()
return part:Clone()
end
local function reflect(vector, normal)
return -2 * vector:Dot(normal) * normal + vector;
end
function VisualiseRay(Start,Direction,Distance)
local Params = RaycastParams.new()
local Result = workspace:Raycast(Start,Start+(Direction*Distance),Params)
local End = (Start + (Direction*Distance))
local rayPart = CreateVisualRayPart()
if Result then
End = Result.Position or End
rayPart.BrickColor = BrickColor.new("Lime green")
rayPart.Size = Vector3.new(0.05, 0.05, (Start- End).Magnitude)
rayPart.CFrame = CFrame.new((Start + End)/2,End)
rayPart.Material = Enum.Material.Neon
spawn(function()
task.wait(3)
rayPart:Destroy()
end)
rayPart.Parent = workspace
return reflect(Direction,Result.Normal),End
else
rayPart.Size = Vector3.new(0.05, 0.05, (Start- End).Magnitude)
rayPart.CFrame = CFrame.new((Start + End)/2,End)
rayPart.Material = Enum.Material.Neon
game.Debris:AddItem(rayPart,5)
rayPart.Parent = workspace
end
return Direction,End
end
while true do task.wait()
local LastDirection = Vector3.zero
local Direction,End = VisualiseRay(Vector3.new(10,12,10),Vector3.new(math.random(-100,100),math.random(-100,100),math.random(-100,100)).Unit,100)
local Bounces = 30
while Bounces > 0 do
Bounces -= 1
LastDirection = Direction
Direction,End = VisualiseRay(End,Direction,100)
end
end
Does anybody know why this is happening, or how I can fix it? Because it’s really troubling when i’m trying to use raycasts for things like projectile systems, sound systems, or anything that needs a large number of collision checks.

