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

How do I transform CFrames in this way...?

Asked by
Supint 60
9 years ago

There are times when, despite a character animation playing, I want to maintain the same position for a certain body part (e.g., the right arm). That is to say, while technically the entire character is being animated, I want the right arm to not move at all and stay at the CFrame dictated by the right shoulder's C0 and C1 properties.

I have a pretty solid theory of how to do this, but I need help working out the complicated part.

Every frame I do this:

First take the right arm's CFrame relative to the Torso's.

local cf1 = char.Torso.CFrame:toObjectSpace(char["Right Arm"].CFrame)

Then I get the right arm's CFrame solely from the shoulder joint's perspective.

local cf2 = char.Torso["Right Shoulder"].C0 * char.Torso["Right Shoulder"].C1:inverse()

Now I need to find the "difference" between the two CFrames and rotate the shoulder joint by that difference every frame. How do I this?

Answer this question