ray = workspace:Raycast(pos, dir, rParam)
if ray.Instance:IsA(“Terrain”) then …
It finds every terrain but water.
I can find water terrain with the same settings if I use FindPartOnRayWithIgnoreList() or (the deprecated) FindPartOnRay()
The relevant code:
local ray = Ray.new(pos,dir)
local instance, position, _, mat = workspace:FindPartOnRayWithIgnoreList(ray, {}, false, false)
if instance:IsA(“Terrain”) then …
With this simple code just to try and recreate your issue, I find none of the issues that you’re talking about.
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
function OnClick()
local Params = RaycastParams.new()
local MouseRay = Mouse.UnitRay
local Result = workspace:Raycast(MouseRay.Origin, MouseRay.Direction * 100, Params)
if Result then
print(Result.Instance:IsA("Terrain"), Result.Material)
end
end
Mouse.Button1Down:Connect(OnClick)
I fear it’s your code that’s the problem rather than the :Raycast method itself, specifically the pos and dir vectors.