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

How do you get an orientation to be represented by a CFrame?

Asked by 4 years ago

I have been trying to work a lot with CFrame, specifically the orientations, and I kept encountering a problem where the orientation that you put into the CFrame ends up orienting the object slightly off. I know that one of the solutions is to change orientation instead of CFrame, but for what I am working on, I need to use CFrame. Here is an example of what I mean:

If you have two cubes side by side to each other and you orient one so that it’s orientation is (30,20,10) and put a script in the other that tells it’s CFrame to be CFrame.Angles(30,20,10), the cubes would look different. If you look in the Cube in which you just imputed that CFrame, you will see that it’s orientation is not as a matter of fact (30,20,10). How exactly would you make it's orientation (30,20,10) with CFrame? Anything helps!

1 answer

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

Alright, so!

CFrame.Angles takes radians as inputs, you're giving it degrees!

EDIT: Also, .Angles applies rotations in XYZ order, while .Orientation works with YXZ, so you're meant to use .fromEulerAnglesYXZ to achieve the same result!

Use something to the likes of this:

Part.CFrame=CFrame.fromEulerAnglesYXZ(math.rad(30),math.rad(20),math.rad(10))

(math.rad transforms an angle in degrees to an angle in radians.)

1
Sorry, I forgot to put the radians while writing the question, but you still answered the question. Thanks a lot, and have a good day! greenhamster1 180 — 4y
Ad

Answer this question