What do you want to achieve?
To raycast in the given direction to detect the touched material.
What is the issue?
I’ve done a lot of raycasting in the past with no issue but for some reason when getting UpVector it appears to use LookVector, LookVector as RightVector etc and I can’t figure out why.
What solutions have you tried so far?
I’ve asked some friends as well as google but found no solution as of yet. I’ve tried setting the position of another part at the destination which always appears to go in the correct direction but whenever I then print the material it appears to coincide with a different direction.
local RunService = game:GetService("RunService")
function GetTouchingMaterial(part)
local Location = part.Position + -(part.CFrame.UpVector * 25)
--workspace.Other.CFrame = CFrame.new(Location)
local ray = Ray.new(part.Position, part.CFrame:VectorToWorldSpace(Location))
local _, _, _, material = workspace:FindPartOnRay(ray, part)
return material
end
function FloorMaterial()
local Base = script.Parent
local material = GetTouchingMaterial(Base)
print(material)
end
RunService.Stepped:Connect(FloorMaterial)
I appreciate any advice, thanks for taking the time to read this!