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:
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)