CFrame question

Why is the CFrame of a part not equal to CFrame.New(part.Position, part.CFrame.LookVector)?
I’m quite stupid you see, so if someone could explain this that would be helpful!

Well I’m not very experienced with CFrame’s myself, and their matrix makeup and all, but I believe this is why.

Because BasePart.CFrame represents the position and orientation of the object in a matrix of these values. On the other hand, CFrame.new(part.Position, part.CFrame.LookVector), if it works as I’d imagine, uses the LookVector of the part as the rotational 3x3 matrix, instead of the normal orientation.

So basically, by using .LookVector, you’re pointing the CFrame in the direction of where the front of the part is facing, through use of what’s called a “unit vector” (a.k.a direction vector). On the other hand, the typical BasePart.CFrame represents the overall orientation of the part.

1 Like

Have you tried the developer.roblox.com site?
Or other posts here?
I need help to understand CFrame - #14 by LordEmotionless

CFrame.new(pos, lookat), otherwise equivalent to CFrame.lookAt(pos, lookat) expects both vectors to be a position in world space, where the vector is originating from the absolute world origin (0, 0, 0), not where the lookat is a relative, unit vector ( a vector with a magnitude of 1, representing a direction)

LookVector is a unit vector representing the direction where the CFrame is facing, meaning that this vector is only 1 stud away from the origin. Recall what was said before

expects both vectors to be a position in world space, where the vector is originating from the absolute world origin (0, 0, 0), not where the lookat is a relative, unit vector

So, this constructor treats it as a vector in world space you want to look at, generating a cframe that is looking 1 stud away from the origin, facing the direction of the part, applying a different orientation than what it originally was. So, part.CFrame ~= CFrame.new(part.Position, part.CFrame.LookVector)

2 Likes

Righto thank you, I was thinking that the lookat was supposed to be a rotation but its just a position in the world space, kinda dumb of me…

even if it was a rotation it’d still be wrong to use lookVector tho