I been doing research and I have fell on this topic that I am interested in learning. Although I don’t fully understand how this works and how I would use it in the future for my works.
I’m trying to get a cube’s front face. Here is what I seen so far.
local frontFaceCF = cube.CFrame * CFrame.new(0,0,-cube.Size.Z/2)
I don’t understand how that is getting the front face…
I have also been doing research on look vectors but still nothing understood.
Would anybody mind giving code samples or explaining me how it works?
-cube.CFrame.LookVector will give you the direction of your front face. Multiply that with the Z size divided by 2 and add it to the position and you’ll get the front face’s position.
A part’s CFrame represents the center of the part, what your code is doing is getting the center of the part (by doing part.CFrame) and then moving it half it’s size along the z axis (getting the side of the part).
Think of it like this: The part is 3 studs long. The part’s cframe represents the center of it. (The cframe is 1.5 studs from it’s left side and 1.5 studs from it’s right side). Now you’re moving the cframe half the part’s size (1.5 studs) along the z axis, so now the cframe is located at the side of the part.