Trying to change Z Orientation of RootJoint Motor6D. But instead it is offset from Y

My RootJoint has C0 Orientation Values of -90, 180, 0 and C1 Values of -90, 180, 0 as well. I am trying to change the Z Orientation to 5 in C0 so that it gives me a result of -90, 180, 5 to simulate character tilting left or right. However Z remains as 0. While 5 is offset from Y giving me a result of -90, -175, 0 producing wildly different results. In order to actually change the Z values I need to change the X values to be something that isn’t 90 or -90 which obviously fixes the problem at the cost of starting another with X instead.

  rootJoint.C0 = CFrame.Angles(math.rad(90), math.rad(180), math.rad(5)) 

Before running the script:

After Running the script:
image

Solved it by setting Z first, then multiplying it by X and then finally Y. It doesn’t give you the same exact CFrame you set it to but the visual results are the same.

rootJoint.C0 = CFrame.Angles(0, 0, zAngle) * CFrame.Angles(xAngle, 0, 0) * CFrame.Angles(0, yAngle, 0)

You should instead be using CFrame.fromEulerAngles which does the exact same thing but without typing all of that out every time:

rootJoint.C0 = CFrame.fromEulerAngles(xAngle, yAngle, zAngle, Enum.RotationOrder.ZXY)
1 Like

Thanks. That’s pretty convenient.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.