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

CFrame basics and how to use it?

Asked by 4 years ago
Edited 4 years ago

I'm try to learn CFrame in Roblox Developer Site but got nothing, so i'm here for asking you guy about CFrame.

2 answers

Log in to vote
2
Answered by 4 years ago
Edited 4 years ago

I'm going to give you a small explanation here.

CFrame stands for CoordinateFrame.

You can use CFrams to change positions of Parts in three dimensional space.

Part.CFrame = CFrame.New(89,34,13)

If you wanted to add position to a CFrame, you would do so using Vector3

Part.CFrame = CFrame.New(89,34,13) + Vector.new(3,2,5)

You cannot compare CFrames like this.

 if CFrame.new(5,2,8) > CFrame.New(89,34,13) then --this won't work.
end

To compare CFrames, you would need to do it for a specific axis.

 if 40 > Part.CFrame.X then --this will work.
end

If you want to change the rotation of something.

Part.CFrame = Part.CFrame * CFrame.Angles(0,0,math.rad(30))

That's just the basics and a small part of CFrames. In reality, CFrames are a lot more complicated, but this is all basic roblox programmers would need to know.

1
very well explained answer royaltoe 5144 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

CFrames are a complicated but very important aspect of Roblox development. You might be able to understand them better if you first learn about vectors and matrices, if you haven't learned about them in school already.

Take a look at this page on the wiki, I find it gives a very good explanation: https://developer.roblox.com/en-us/articles/Understanding-CFrame

0
Actually, i haven't learn about vectors and matrices before, but thank for your advice. Block_manvn 395 — 4y
0
don't need to learn about vectors and matricies initially really. You can get by with understanding the basics in that wiki link. If you want to get onto more complicated stuff, then vectors and matricies, yeah, they're helpful. royaltoe 5144 — 4y
0
CFrames are matrices, so if you understand how to manipulate a matrix, you will understand much better how CFrame works. cowsoncows 951 — 4y

Answer this question