Raycasting offset issue

Hello guys, I was stuck at this problem because I like being independent… completely forgot I have the help of thousands of people at disposal thanks to this well crafted site :smiley:

The issue is that I want to offset a the origin of the raycast from rootpart which I was able to do by simply
local origin = rootpart.CFrame*CFrame.new(-4,0,1).Position

what i’m struggling to do is actually get the direction perfect, what I want to do is make it so it’s slightly diagonal what i’ve done so far was…
local direction = rootpart.CFrame.lookVector+rootpart.CFrame.RightVector*20

An awful representation of this would be
image

you can take the rootpart’s cframe and rotate it, then take the look vector of that new cframe as your direction

local direction = rootpart.CFrame*CFrame.Angles(x,y,z).LookVector

where x,y,z are the angles to rotate. looking at your drawing it seems like you would want to rotate it about the y axis, so have x=0, z=0, and set y to the angle

1 Like