Im making a system where I have a raycast for every side of a block to see if the sides next to it are clear to path to, only problem is the raycast never returns a result and I dont konw.
function module.getFreeSide(block, minionPosition, minion)
local bestPos = nil
local shortestDist = math.huge
for _, offset in pairs(directions) do
local checkPos = block.Position + offset
local origin = checkPos + Vector3.new(0, 5, 0)
--module.createDebugPart(origin)
local direction = Vector3.new(0, -15, 0)
local params = RaycastParams.new()
params.FilterDescendantsInstances = {minion}
params.FilterType = Enum.RaycastFilterType.Exclude
local result = workspace:Raycast(origin, direction, params)
module.createDebugPart(origin)
module.createDebugPart(origin + direction)
if not result then
print("no raycast result " .. minion.Name)
end
if result and result.Instance and result.Instance.CanCollide then
local dist = (minionPosition - checkPos).Magnitude
if dist < shortestDist then
shortestDist = dist
bestPos = checkPos
end
end
end
return bestPos
end
The green blocks are the debug points, its raycasting down and should be hitting the other blocks but its not and I dont know why. It always prints no raycast result