I was watching a tutorial on raycasting, and they were talking about how the turret(they made a turret to example raycasting)turned towards something, can you explain to me what CFrame is?
✓ ANSWER ACCEPTED
What isa CFrame? How do I use it? What can it be used to do?
2 answers
✓ Accepted answer
CFrame is used to position something and also set it's orientation (rotation).
Basically, Vector3 with orientation.
CFrame is the position, as well as orientation and a few other aspects, of a BasePart. The most used arguments of CFrame are the first 2: Position and LookVector. Position is the Position of the part, and LookVector is where the part faces.
An example:
-- Make Part1 teleport to Part2 and face towards Part3
workspace.Part1.CFrame = CFrame.new(workspace.Part2.Position, workspace.Part3.Position);
You can also do some math and multiply CFrames to get offsets and rotations in relation to the initial CFrame you're multiplying.
Here are some resources to help you get started with CFrames:
This discussion is preserved as it was. New answers, comments, and votes are closed.
