Blue - Direction
Green - The final result, the position of the raycast
Despite the fact that the Direction is aimed strictly straight ahead, the position appears in a completely random place, as if.
Front of this Part OneSideCollision.rbxl (51.4 KB)
local function Raycast()
local Origin = Character.PrimaryPart.Position;
local Direction = (Part.Position + Part.CFrame.LookVector * 2 - Origin);
local Parameters = RaycastParams.new(); do
Parameters.FilterType = Enum.RaycastFilterType.Blacklist;
Parameters.FilterDescendantsInstances = { Character };
end
local Raycast = workspace:Raycast(Origin, Direction, Parameters);
if Raycast and Raycast.Instance then
MakeItOpen(false, tostring(Raycast));
else
MakeItOpen(true, "Raycast was not successfull!");
end
VisualizeRaycast(workspace.RaycastPart, workspace.RaycastPositionPart, Origin, Part.Position + Part.CFrame.LookVector * 2, Raycast);
return;
end
Your issue was that you were using raycasts wrong, the 2nd parameter is supposed to be the direction of where the ray goes, not the position of where the ray goes.