Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Can someone explain me Cframes I dont quite understand it?

Asked by 4 years ago

Can someone explain to me Cframes I don't quite understand it I have seen it used in a lot of games for Intros but I don't understand it and how are they used

2 answers

Log in to vote
1
Answered by 4 years ago

Hello there!

What are CFrames?

CFrames are basically position (Vector3) and rotation (Also Vector3) combined. CFrames are short for Coordinate Frame.

Why to use them?

You'd want to use a CFrame when you're trying to rotate and position a part at the same time.

How to use them?

You can either use them to set the position or rotation.

Here's an example:

script.Parent.CFrame = CFrame.new(0,5, 0) * CFrame.Angles(math.rad(10), 0, 0)

That would set the part's position to "0, 5, 0" and rotation to "10, 0, 0".

When adding a CFrame to another CFrame, you must use the multiplying letter (*). You also must use math.rad() for CFrame.Angles() as CFrame uses radiants instead of degrees.

Another example is adding only rotation to a part.

script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(math.rad(10), 0, 0)

You must add the part's current CFrame with the new angle. If you didn't do that, the part would get positioned to "0, 0, 0".

Sorry if you still don't understand it, as CFrames are a bit hard to understand. I recommend watching this if you still don't understand it.

Anyways, make sure to accept this answer if it helps.

Ad
Log in to vote
2
Answered by
JesseSong 3916 Moderation Voter Community Moderator
4 years ago
Edited 3 years ago

What are CFrames?

CFrames is an acronym for Coordinate Frame. CFrame is a type of data used in 3D objects like parts, spheres etc. CFrames describe the orientation and position of a part, like how they move and also, CFrames can also be used for rotating an object.

How do you use a CFrame?

Here's an example of CFrame

local cf = CFrame.new(0, 5, 0) * CFrame.Angles(math.rad(45), 0, 0)

This will set the coordinates to 5 studs above.

What are the benefits of using CFrames?

CFrames are beneficial for describing such properties in the studio, like look-vector, right-vector raycasting, etc. CFrames are very useful to work with. Here's an example

Also, when working with CFrames, you must use math.rad. Math.Rad stands for math.radians hence the name. When working with CFrame.Angle you must use the math.rad function, because CFrames utilizes radians and converts them to radians instead of degrees.

CFrames are essential for rotating and positioning a 3D Dimensional object in the workspace.

Re-edited on 2/Feb/2021 - Fixed grammatical errors

0
Fixed minor errors. Date: 19/02/21 JesseSong 3916 — 3y

Answer this question