CFrame Roation Help

I’m not very good with CFrame rotation math. So right now I’m trying to cast a ray that only follows one axis of rotation of a part while maintaining the same constant angle for the rest. Here is an example.

The line below is what I have however it follows all 3 axis’s of rotation rather than one., Part.CFrame:vectorToWorldSpace(, 0, -1)).unit * 200)

Id just use the built in CFrame properties

So like, Part.CFrame.rightVector.unit * 200)
If you wanted to make it go left just make it -200. Same for upVector and lookVector

Correct me if I’m wrong but you’re wanting to cast a ray in the direction a part is pointing, but keep it flat (parallel to the ground)?
You can achieve this by getting the lookVector of your part and setting the y (vertical) component to 0;

direction =,0,part.CFrame.lookVector.Z).Unit

Thank you for the help!

1 Like

If you want to neaten this up a bit you can go for:

local dir = (part.CFrame.lookVector *, 0, 1)).unit
1 Like