Hey, trying to figure out how i can get the closest part which is in a direcition
using dot and magnitudes
i think i have a start atleast:
function Climbing:GetClosestClimbableToDir(CurrentClimbable:BasePart,ToCompare)
local Climbables = workspace.Climbables:GetChildren()
for i,Climbable:BasePart in pairs(Climbables) do
local CF = Climbable.CFrame
Climbables[i] = {
(CurrentClimbable.Position - Climbable.Position).Magnitude,
(-CF[ToCompare]):Dot(CurrentClimbable.CFrame[ToCompare]),
Climbable
}
end
table.sort(Climbables,function(a,b)
return a[1] < b[1] and a[2] > b[2]
end)
print(Climbables)
return Climbables[1]
end
if anyone knows a way to fix it or have a solution i’d appreciate it