I can’t understand those topics. They’ve been bugging me for months. It would be really helpful if you give me an example on how to use it. Thank You
CFrame is just like Vector3 EXPECT that CFrames have orientation in them.
I see. Ok so which one would I use and how? I moved a part with both and both worked perfectly fine.
So if you would do Part1.CFrame = Part2.CFrame it would bring part1 to part2 Position AND also rotate it to Part2 rotation.
If you also want Orientation in it you should use CFrame, if not Vector
CFrame:
Position + Orientation
Raycasting:
It can be used to know if there is an object in a direction
So Part1.Position = Part2.Position is the Same as Part1.CFrame = Part2.CFrame expect that CFrame gives Part1 the orientation that Part2 has, Vector does NOT
So what happens if I change a part’s position like this.
local part = game.Workspace.Part
part.CFrame = CFrame.new(100, 9, 100)
That actually doesn’t give orientation, it is just like Vector3 now, to give it orientation you need to set Part1 CFrame to Part2 CFrame
Finally a good answer. So which do you use most more and which scenarios would you use CFrame with?
If you still want to give it orientation but don’t set it to Part2 CFrame, just use Instance.Orientation
You use CFrame when you want Part1 to get Part2 Position and Orientation
And I often use CFrames when I want the position of Part1 be the same as Part2 and also have the orientation of Part1 be the same as part2
So if I would change a part’s position, I’d do
local part = game.Workspace.Part
part.CFrame = CFrame.new(70, 10, 8) -- Position??
To change orientation, I’d do:
local part = game.Workspace.Part
part.CFrame *= CFrame.Angles(0, math.rad(100), 0)
Here you could use Vector3, because now this CFrame is the same as a Vector
Cuz you don’t set the CFrame from Part1 to Part2
And CFrame only changes position AND orientation when you set Part1 CFrame to Part2 CFrame. And if you don’t set the CFrame of Part1 to Part2 and still want to have a different orientation, just do Part1.Orientation = Vector3.new([any orientation you want here])
I never want a part’s position and orientation to be the same as another part. I think. so why would I ever use CFrame???
I mean if you don’t want a part‘s Position and orientation to be the same as the other one then you can just use Vector3. CFrame is just Vector3 + orientation built in