From b6c40c83906b87c5bc43f642b102e0489c29d636 Mon Sep 17 00:00:00 2001 From: OptimisticSide <47266822+optimisticside@users.noreply.github.com> Date: Sat, 2 Apr 2022 13:12:24 -0700 Subject: [PATCH] Use WorldRoot:Raycast I have replaced the `WorldRoot:FindPartOnRayWithIgnoreList` method with `WorldRoot:Raycast`. --- src/raycaster/src/Shared/Raycaster.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/raycaster/src/Shared/Raycaster.lua b/src/raycaster/src/Shared/Raycaster.lua index 14be59c078..aca46f86b5 100644 --- a/src/raycaster/src/Shared/Raycaster.lua +++ b/src/raycaster/src/Shared/Raycaster.lua @@ -134,23 +134,27 @@ function Raycaster:__newindex(index, value) end function Raycaster:_tryCast(ray, ignoreList) - local part, position, normal, material = Workspace:FindPartOnRayWithIgnoreList( - ray, ignoreList, false, self._ignoreWater) + local raycastParams = RaycastParams.new() + raycastParams.IgnoreWater = self._ignoreWater + raycastParams.FilterDescendantsInstances = ignoreList + raycastResult.FilterType = Enum.RaycastFilterType.Blacklist - if not part then + local raycastResult = Workspace:Raycast(ray.Origin, ray.Direction, raycastParams) + if not raycastResult.Instance then return true, nil end local data = { - Part = part; - Position = position; - Normal = normal; - Material = material; + Part = raycastResult.Instance; + Position = raycastResult.Position; + Normal = raycastResult.Normal; + Material = raycastResult.Material; + Distance = raycastResult.Distance; } local filter = self.Filter if filter and filter(data) then - table.insert(ignoreList, part) + table.insert(ignoreList, raycastResult.Instance) return false, nil end