Help positioning arms relative to axis

So I mostly have everything working the way I want it. I have a script that rotates parts of the player model to follow the player’s camera. Here’s an example of a part of the code that smoothly moves a bone to follow the camera

DEF_SPINE3.CFrame = CFrame.fromOrientation(
			math.rad(-0.186 + (Pos.X * 0.1)), 
			math.rad(Pos.Y), 
			0) + DEF_SPINE3.CFrame.Position

DEF_SPINE3 is the bone for a link of the player’s spine. It is rotated to follow the player’s camera by about 10%. the -0.186 in the first argument is needed to account for the original rotation of the bone before moving it. This allows for the player model to look just like it did before when the camera is pointing straight ahead, but will still rotate to follow the camera. POS.X is the vertical rotation of the camera, and moves the spine up and down in relation to the camera. POS.Y is the horizontal rotation of the camera and twists the spine to follow the camera.

Some pretty simple math right? the spine was originally tilted about -0.186 degrees back, so if I move the camera X degrees and subtract -0.186 degrees, It will look just as it did before and rotate to follow the camera.

Here’s where things get tricky:

LArm.CFrame = CFrame.fromOrientation(
	math.rad(-12.358), 
	math.rad(43.604 + Pos.X * .9), 
	math.rad(32.809)
) + LArm.CFrame.Position

Now the arm has 3 axis of rotation that need to be accounted for! If I just rotate it on the Y axis, It wont reflect on the other axis and wont rotate perpendicular to the player’s posture as intended:

a70b6af84a187e84102f953dbd981cb3

I know there is a trigonometric solution for this, I just dont know the math. Does anyone know of a way to figure this out? The left arm’s original orientation is (-12.358, 43.604, 32.809), and the right arm’s original orientation is (-25.567, 34.957, -149.071)

Two things, I’m not sure what exactly you intend to account for? (Just confused, maybe explain a bit more thoroughly?)
But also I see you’re trying to sum up a CFrame and a Vector3…?

1 Like

Its pretty tough to visualize the problem without access to the rig.

However I can give you the idea of doing the rotation in seperate parts and adjust the CFrame order of operations to mess around with the axis of rotation or adding another one to account for any offsets.

Doing CFrame1 * CFrame2 can be different from CFrame2 * CFrame1 and lead to a different rotational axis.

1 Like

Allow me to put it this way: The bone’s CFrame has an orientation attribute that is rotated about X, Y and Z values, represented in the picture by the green, blue and red lines. But I want to rotate the bone about the yellow dotted line instead. How would I do this?